Changeset 36275 in osm for applications
- Timestamp:
- 2024-06-06T17:48:26+02:00 (7 months ago)
- Location:
- applications/editors/josm/plugins/photo_geotagging
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/photo_geotagging/src/org/openstreetmap/josm/plugins/photo_geotagging/ExifGPSTagger.java
r35933 r36275 1 // Wrapper class for sanselan library 1 // License: GPL. For details, see LICENSE file. 2 // SPDX-License-Identifier: GPL-2.0-or-later 2 3 package org.openstreetmap.josm.plugins.photo_geotagging; 3 4 … … 11 12 import java.time.Instant; 12 13 import java.util.Calendar; 13 import java.util.Date;14 14 import java.util.GregorianCalendar; 15 15 import java.util.TimeZone; 16 16 17 import org.apache.commons.imaging.ImageReadException;18 import org.apache.commons.imaging.ImageWriteException;19 17 import org.apache.commons.imaging.Imaging; 18 import org.apache.commons.imaging.ImagingException; 20 19 import org.apache.commons.imaging.common.ImageMetadata; 21 20 import org.apache.commons.imaging.common.RationalNumber; … … 28 27 import org.apache.commons.imaging.formats.tiff.write.TiffOutputSet; 29 28 30 public class ExifGPSTagger { 29 /** 30 * Wrapper class for sanselan library 31 */ 32 public final class ExifGPSTagger { 33 private ExifGPSTagger() { 34 // Hide constructor 35 } 36 31 37 /** 32 38 * Set the GPS values in JPEG EXIF metadata. … … 44 50 * @throws IOException in case of I/O error 45 51 */ 46 public static void setExifGPSTag(File imageFile, File dst, double lat, double lon, Instant gpsTime, Double speed, Double ele, Double imgDir, boolean lossy) throws IOException { 52 public static void setExifGPSTag(File imageFile, File dst, double lat, double lon, Instant gpsTime, Double speed, 53 Double ele, Double imgDir, boolean lossy) throws IOException { 47 54 try { 48 55 setExifGPSTagWorker(imageFile, dst, lat, lon, gpsTime, speed, ele, imgDir, lossy); 49 } catch (ImageReadException ire) { 50 throw new IOException(tr("Read error: "+ire), ire); 51 } catch (ImageWriteException ire2) { 52 throw new IOException(tr("Write error: "+ire2), ire2); 56 } catch (ImagingException ire) { 57 // This used to be two separate exceptions; ImageReadException and imageWriteException 58 throw new IOException(tr("Read/write error: " + ire.getMessage()), ire); 53 59 } 54 60 } 55 61 56 public static void setExifGPSTagWorker(File imageFile, File dst, double lat, double lon, Instant gpsTime, Double speed, Double ele, Double imgDir, boolean lossy)57 throws IOException, ImageReadException, ImageWriteException {62 public static void setExifGPSTagWorker(File imageFile, File dst, double lat, double lon, Instant gpsTime, Double speed, 63 Double ele, Double imgDir, boolean lossy) throws IOException { 58 64 59 65 TiffOutputSet outputSet = null; … … 73 79 } 74 80 75 TiffOutputDirectory gpsDirectory = outputSet.getOrCreateG PSDirectory();81 TiffOutputDirectory gpsDirectory = outputSet.getOrCreateGpsDirectory(); 76 82 gpsDirectory.removeField(GpsTagConstants.GPS_TAG_GPS_VERSION_ID); 77 83 gpsDirectory.add(GpsTagConstants.GPS_TAG_GPS_VERSION_ID, (byte)2, (byte)3, (byte)0, (byte)0); … … 112 118 } 113 119 114 outputSet.setG PSInDegrees(lon, lat);120 outputSet.setGpsInDegrees(lon, lat); 115 121 116 122 if (speed != null) { -
applications/editors/josm/plugins/photo_geotagging/src/org/openstreetmap/josm/plugins/photo_geotagging/GeotaggingAction.java
r35933 r36275 1 //License: GPL (v2 or later) 1 // License: GPL. For details, see LICENSE file. 2 // SPDX-License-Identifier: GPL-2.0-or-later 2 3 package org.openstreetmap.josm.plugins.photo_geotagging; 3 4 … … 8 9 import java.awt.Component; 9 10 import java.awt.Dimension; 11 import java.awt.GridBagConstraints; 10 12 import java.awt.GridBagLayout; 11 13 import java.awt.event.ActionEvent; … … 17 19 import java.time.Instant; 18 20 import java.util.ArrayList; 19 import java.util.Date;20 21 import java.util.List; 22 import java.util.Locale; 21 23 import java.util.UUID; 22 24 … … 35 37 import javax.swing.UIManager; 36 38 37 import org.apache.commons.imaging. formats.jpeg.exif.ExifRewriter;39 import org.apache.commons.imaging.ImagingOverflowException; 38 40 import org.apache.commons.io.FilenameUtils; 39 41 import org.openstreetmap.josm.gui.ExtendedDialog; … … 57 59 class GeotaggingAction extends AbstractAction implements LayerAction { 58 60 59 final staticString KEEP_BACKUP = "plugins.photo_geotagging.keep_backup";60 final staticString CHANGE_MTIME = "plugins.photo_geotagging.change-mtime";61 final staticString MTIME_MODE = "plugins.photo_geotagging.mtime-mode";62 final staticint MTIME_MODE_GPS = 1;63 final staticint MTIME_MODE_PREVIOUS_VALUE = 2;61 static final String KEEP_BACKUP = "plugins.photo_geotagging.keep_backup"; 62 static final String CHANGE_MTIME = "plugins.photo_geotagging.change-mtime"; 63 static final String MTIME_MODE = "plugins.photo_geotagging.mtime-mode"; 64 static final int MTIME_MODE_GPS = 1; 65 static final int MTIME_MODE_PREVIOUS_VALUE = 2; 64 66 65 67 public GeotaggingAction() { … … 88 90 if (e.getPos() != null && e.hasNewGpsData()) { 89 91 String pth = e.getFile().getAbsolutePath(); 90 switch (FilenameUtils.getExtension(pth).toLowerCase( )) {92 switch (FilenameUtils.getExtension(pth).toLowerCase(Locale.ENGLISH)) { 91 93 case "tif": 92 94 case "tiff": … … 113 115 JScrollPane scroll = new JScrollPane(entryList); 114 116 scroll.setPreferredSize(new Dimension(900, 250)); 115 cont.add(scroll, GBC.eol().fill(G BC.BOTH));117 cont.add(scroll, GBC.eol().fill(GridBagConstraints.BOTH)); 116 118 117 119 if (notSupportedFilesCount > 0) { … … 119 121 ? tr("The file \"{0}\" can not be updated. Only JPEG and TIFF images are supported.", notSupportedName) 120 122 : trn("{0} file can not be updated. Only JPEG and TIFF images are supported.", 121 "{0} files can not be updated. Only JPEG and TIFF images are supported.", notSupportedFilesCount, notSupportedFilesCount)); 123 "{0} files can not be updated. Only JPEG and TIFF images are supported.", 124 notSupportedFilesCount, notSupportedFilesCount)); 122 125 warn.setForeground(Color.RED); 123 126 cont.add(warn, GBC.eol()); … … 203 206 204 207 static class GeoTaggingRunnable extends PleaseWaitRunnable { 205 final privateList<ImageEntry> images;206 final privateboolean keep_backup;207 final privateint mTimeMode;208 private final List<ImageEntry> images; 209 private final boolean keep_backup; 210 private final int mTimeMode; 208 211 209 212 private boolean canceled = false; … … 288 291 processEntry(e, lossy); 289 292 } catch (final IOException ioe) { 290 ioe.printStackTrace();293 Logging.trace(ioe); 291 294 restoreFile(); 292 if (!lossy && ioe.getCause() instanceof ExifRewriter.ExifOverflowException) {295 if (!lossy && ioe.getCause() instanceof ImagingOverflowException) { 293 296 exifFailedEntries.add(e); 294 297 } else { -
applications/editors/josm/plugins/photo_geotagging/src/org/openstreetmap/josm/plugins/photo_geotagging/GeotaggingPlugin.java
r35715 r36275 1 //License: GPL (v2 or above) 1 // License: GPL. For details, see LICENSE file. 2 // SPDX-License-Identifier: GPL-2.0-or-later 2 3 package org.openstreetmap.josm.plugins.photo_geotagging; 3 4 … … 11 12 * It extends the core geoimage feature of JOSM by adding a new entry 12 13 * to the right click menu of any image layer. 13 * 14 * <p> 14 15 * The real work (writing lat/lon values to file) is done by the pure Java 15 16 * sanselan library.
Note:
See TracChangeset
for help on using the changeset viewer.