Changeset 28398 in osm
- Timestamp:
- 2012-05-20T23:04:34+02:00 (12 years ago)
- Location:
- applications/editors/josm/plugins/photo_geotagging
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/photo_geotagging/build.xml
r27401 r28398 25 25 26 26 <!-- 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)"/> 28 28 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 29 29 <property name="plugin.main.version" value="4762"/> -
applications/editors/josm/plugins/photo_geotagging/src/org/openstreetmap/josm/plugins/photo_geotagging/ExifGPSTagger.java
r22553 r28398 22 22 import org.apache.sanselan.formats.tiff.TiffImageMetadata; 23 23 import org.apache.sanselan.formats.tiff.constants.GPSTagConstants; 24 import org.apache.sanselan.formats.tiff.fieldtypes.FieldType; 24 25 import org.apache.sanselan.formats.tiff.write.TiffOutputDirectory; 25 26 import org.apache.sanselan.formats.tiff.write.TiffOutputField; … … 36 37 * @param lon longitude 37 38 * @param gpsTime time in milliseconds 39 * @param ele elevation - can be null if not available 38 40 */ 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 { 40 42 try { 41 setExifGPSTagWorker(jpegImageFile, dst, lat, lon, gpsTime );43 setExifGPSTagWorker(jpegImageFile, dst, lat, lon, gpsTime, ele); 42 44 } catch (ImageReadException ire) { 43 throw new IOException(tr("Read error !"));45 throw new IOException(tr("Read error: "+ire), ire); 44 46 } catch (ImageWriteException ire2) { 45 throw new IOException(tr("Write error !"));47 throw new IOException(tr("Write error: "+ire2), ire2); 46 48 } 47 49 } 48 50 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, 50 52 ImageReadException, ImageWriteException 51 53 { … … 109 111 SanselanFixes.setGPSInDegrees(outputSet, lon, lat); 110 112 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 111 130 os = new FileOutputStream(dst); 112 131 os = new BufferedOutputStream(os); -
applications/editors/josm/plugins/photo_geotagging/src/org/openstreetmap/josm/plugins/photo_geotagging/GeotaggingAction.java
r27401 r28398 212 212 chooseFiles(e.getFile()); 213 213 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()); 215 215 216 216 if (mTimeMode == MTIME_MODE_GPS) {
Note:
See TracChangeset
for help on using the changeset viewer.