Ignore:
Timestamp:
2012-05-20T23:04:34+02:00 (12 years ago)
Author:
bastik
Message:

write elevation to EXIF (see josm #7710)

Location:
applications/editors/josm/plugins/photo_geotagging
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/photo_geotagging/build.xml

    r27401 r28398  
    2525
    2626    <!-- enter the SVN commit message -->
    27     <property name="commit.message" value="fixed josm bug 5800 - 'Override old backup files?' message window can't get focus"/>
     27    <property name="commit.message" value="write elevation to EXIF (see josm #7710)"/>
    2828    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    2929    <property name="plugin.main.version" value="4762"/>
  • applications/editors/josm/plugins/photo_geotagging/src/org/openstreetmap/josm/plugins/photo_geotagging/ExifGPSTagger.java

    r22553 r28398  
    2222import org.apache.sanselan.formats.tiff.TiffImageMetadata;
    2323import org.apache.sanselan.formats.tiff.constants.GPSTagConstants;
     24import org.apache.sanselan.formats.tiff.fieldtypes.FieldType;
    2425import org.apache.sanselan.formats.tiff.write.TiffOutputDirectory;
    2526import org.apache.sanselan.formats.tiff.write.TiffOutputField;
     
    3637     * @param lon longitude
    3738     * @param gpsTime time in milliseconds
     39     * @param ele elevation - can be null if not available
    3840     */
    39     public static void setExifGPSTag(File jpegImageFile, File dst, double lat, double lon, long gpsTime) throws IOException {
     41    public static void setExifGPSTag(File jpegImageFile, File dst, double lat, double lon, long gpsTime, Double ele) throws IOException {
    4042        try {
    41             setExifGPSTagWorker(jpegImageFile, dst, lat, lon, gpsTime);
     43            setExifGPSTagWorker(jpegImageFile, dst, lat, lon, gpsTime, ele);
    4244        } catch (ImageReadException ire) {
    43             throw new IOException(tr("Read error!"));
     45            throw new IOException(tr("Read error: "+ire), ire);
    4446        } catch (ImageWriteException ire2) {
    45             throw new IOException(tr("Write error!"));
     47            throw new IOException(tr("Write error: "+ire2), ire2);
    4648        }
    4749    }
    4850
    49     public static void setExifGPSTagWorker(File jpegImageFile, File dst, double lat, double lon, long gpsTime) throws IOException,
     51    public static void setExifGPSTagWorker(File jpegImageFile, File dst, double lat, double lon, long gpsTime, Double ele) throws IOException,
    5052            ImageReadException, ImageWriteException
    5153    {
     
    109111            SanselanFixes.setGPSInDegrees(outputSet, lon, lat);
    110112
     113            if (ele != null) {
     114                byte eleRef =  ele >= 0 ? (byte) 0 : (byte) 1;
     115                TiffOutputField gpsAltitudeRef = new TiffOutputField(
     116                        GPSTagConstants.GPS_TAG_GPS_ALTITUDE_REF,
     117                        FieldType.FIELD_TYPE_BYTE, 1, new byte[] { eleRef });
     118                exifDirectory.removeField(GPSTagConstants.GPS_TAG_GPS_ALTITUDE_REF);
     119                exifDirectory.add(gpsAltitudeRef);
     120
     121                Number[] val = new Number[] { Math.abs(ele) };
     122                byte[] bytes = FieldType.FIELD_TYPE_RATIONAL.writeData(val, outputSet.byteOrder);
     123                TiffOutputField gpsAltitude = new TiffOutputField(
     124                        GPSTagConstants.GPS_TAG_GPS_ALTITUDE,
     125                        FieldType.FIELD_TYPE_RATIONAL, 1, bytes);
     126                exifDirectory.removeField(GPSTagConstants.GPS_TAG_GPS_ALTITUDE);
     127                exifDirectory.add(gpsAltitude);
     128            }
     129
    111130            os = new FileOutputStream(dst);
    112131            os = new BufferedOutputStream(os);
  • applications/editors/josm/plugins/photo_geotagging/src/org/openstreetmap/josm/plugins/photo_geotagging/GeotaggingAction.java

    r27401 r28398  
    212212                    chooseFiles(e.getFile());
    213213                    if (canceled) return;
    214                     ExifGPSTagger.setExifGPSTag(fileFrom, fileTo, e.getPos().lat(), e.getPos().lon(), e.getGpsTime().getTime());
     214                    ExifGPSTagger.setExifGPSTag(fileFrom, fileTo, e.getPos().lat(), e.getPos().lon(), e.getGpsTime().getTime(), e.getElevation());
    215215
    216216                    if (mTimeMode == MTIME_MODE_GPS) {
Note: See TracChangeset for help on using the changeset viewer.