- Timestamp:
- 2025-07-12T18:15:02+02:00 (4 months ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 7 edited
-
data/gpx/GpxImageCorrelation.java (modified) (11 diffs)
-
data/gpx/GpxImageCorrelationSettings.java (modified) (6 diffs)
-
data/gpx/GpxImageEntry.java (modified) (1 diff)
-
data/gpx/TimeSource.java (added)
-
gui/layer/geoimage/CorrelateGpxWithImages.java (modified) (12 diffs)
-
gui/layer/geoimage/EditImagesSequenceAction.java (modified) (2 diffs)
-
gui/layer/geoimage/ImageMetadata.java (modified) (2 diffs)
-
gui/layer/geoimage/RemoteEntry.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/gpx/GpxImageCorrelation.java
r19390 r19426 77 77 final GpxImageDatumSettings datumSettings = settings.getDatumSettings(); 78 78 final long offset = settings.getOffset(); 79 final TimeSource imgTimeSource = settings.getImgTimeSource(); 79 80 80 81 boolean isFirst = true; … … 145 146 } 146 147 WayPoint nextWp = i < size - 1 ? wps.get(i + 1) : null; 147 ret += matchPoints(images, prevWp, prevWpTime, curWp, curWpTime, offset, 148 ret += matchPoints(images, prevWp, prevWpTime, curWp, curWpTime, imgTimeSource, offset, 148 149 interpolate, tagTime, nextWp, dirpos, datumSettings); 149 150 prevWp = curWp; … … 153 154 } 154 155 if (trkTag && prevWp != null) { 155 ret += matchPoints(images, prevWp, prevWpTime, prevWp, prevWpTime, offset, 156 ret += matchPoints(images, prevWp, prevWpTime, prevWp, prevWpTime, imgTimeSource, offset, 156 157 false, trkTagTime, null, dirpos, datumSettings); 157 158 } … … 362 363 WayPoint curWp, 363 364 long curWpTime, 365 TimeSource imgTimeSource, 364 366 long offset, 365 367 boolean interpolate, … … 376 378 i = images.size() - 1; 377 379 } else { 378 i = getLastIndexOfListBefore(images, curWpTime); 380 i = getLastIndexOfListBefore(images, curWpTime, imgTimeSource); 379 381 } 380 382 … … 427 429 final GpxImageEntry curImg = images.get(i); 428 430 final GpxImageEntry curTmp = curImg.getTmp(); 429 final long time = curImg.get ExifInstant().toEpochMilli();431 final long time = curImg.getTimeSourceInstant(imgTimeSource).toEpochMilli(); 430 432 if ((!isLast && time > curWpTime) || time < prevWpTime) { 431 433 break; … … 460 462 while (i >= 0) { 461 463 final GpxImageEntry curImg = images.get(i); 462 final long imgTime = curImg.get ExifInstant().toEpochMilli();464 final long imgTime = curImg.getTimeSourceInstant(imgTimeSource).toEpochMilli(); 463 465 if (imgTime < prevWpTime) { 464 466 break; … … 548 550 } 549 551 550 curTmp.setGpsTime(curImg.get ExifInstant().minusMillis(offset));552 curTmp.setGpsTime(curImg.getTimeSourceInstant(imgTimeSource).minusMillis(offset)); 551 553 curTmp.flagNewGpsData(); 552 554 curImg.tmpUpdated(); … … 579 581 * @return index of last image before given time 580 582 */ 581 private static int getLastIndexOfListBefore(List<? extends GpxImageEntry> images, long searchedTime) { 583 private static int getLastIndexOfListBefore(List<? extends GpxImageEntry> images, long searchedTime, TimeSource imgTimeSource) { 582 584 int lstSize = images.size(); 583 585 584 586 // No photos or the first photo taken is later than the search period 585 if (lstSize == 0 || searchedTime < images.get(0).get ExifInstant().toEpochMilli())587 if (lstSize == 0 || searchedTime < images.get(0).getTimeSourceInstant(imgTimeSource).toEpochMilli()) 586 588 return -1; 587 589 588 590 // The search period is later than the last photo 589 if (searchedTime > images.get(lstSize - 1).get ExifInstant().toEpochMilli())591 if (searchedTime > images.get(lstSize - 1).getTimeSourceInstant(imgTimeSource).toEpochMilli()) 590 592 return lstSize-1; 591 593 … … 596 598 while (endIndex - startIndex > 1) { 597 599 curIndex = (endIndex + startIndex) / 2; 598 if (searchedTime > images.get(curIndex).get ExifInstant().toEpochMilli()) {600 if (searchedTime > images.get(curIndex).getTimeSourceInstant(imgTimeSource).toEpochMilli()) { 599 601 startIndex = curIndex; 600 602 } else { … … 602 604 } 603 605 } 604 if (searchedTime < images.get(endIndex).get ExifInstant().toEpochMilli())606 if (searchedTime < images.get(endIndex).getTimeSourceInstant(imgTimeSource).toEpochMilli()) 605 607 return startIndex; 606 608 607 609 // This final loop is to check if photos with the exact same EXIF time follows 608 while ((endIndex < (lstSize - 1)) && (images.get(endIndex).get ExifInstant().toEpochMilli()609 == images.get(endIndex + 1).get ExifInstant().toEpochMilli())) {610 while ((endIndex < (lstSize - 1)) && (images.get(endIndex).getTimeSourceInstant(imgTimeSource).toEpochMilli() 611 == images.get(endIndex + 1).getTimeSourceInstant(imgTimeSource).toEpochMilli())) { 610 612 endIndex++; 611 613 } -
trunk/src/org/openstreetmap/josm/data/gpx/GpxImageCorrelationSettings.java
r19387 r19426 12 12 private final long offset; 13 13 private final boolean forceTags; 14 private final TimeSource imgTimeSource; 14 15 private final GpxImageDirectionPositionSettings directionPositionSettings; 15 16 private final GpxImageDatumSettings datumSettings; … … 21 22 */ 22 23 public GpxImageCorrelationSettings(long offset, boolean forceTags) { 23 this(offset, forceTags, 24 this(offset, forceTags, TimeSource.EXIFCAMTIME, 24 25 new GpxImageDirectionPositionSettings(false, 0, false, 0, 0, 0), 25 26 new GpxImageDatumSettings(false, null) … … 31 32 * @param offset offset in milliseconds 32 33 * @param forceTags force tagging of all photos, otherwise prefs are used 34 * @param imgTimeSource select image clock source: 35 * "exifCamTime" for camera internal clock 36 * "exifGpsTime for the GPS clock of the camera 33 37 * @param directionPositionSettings direction/position settings 38 * @since 19426 @imgTimeSource was added 34 39 */ 35 public GpxImageCorrelationSettings(long offset, boolean forceTags, 40 public GpxImageCorrelationSettings(long offset, boolean forceTags, TimeSource imgTimeSource, 36 41 GpxImageDirectionPositionSettings directionPositionSettings) { 37 this(offset, forceTags, directionPositionSettings, 42 this(offset, forceTags, imgTimeSource, directionPositionSettings, 38 43 new GpxImageDatumSettings(false, null)); 39 44 } … … 43 48 * @param offset offset in milliseconds 44 49 * @param forceTags force tagging of all photos, otherwise prefs are used 50 * @param imgTimeSource select image clock source: 51 * "exifCamTime" for camera internal clock 52 * "exifGpsTime for the GPS clock of the camera 45 53 * @param directionPositionSettings direction/position settings 46 54 * @param datumSettings GPS datum settings 47 55 * @since 19387 @datumSettings was added 56 * @since 19426 @imgTimeSource was added 48 57 */ 49 public GpxImageCorrelationSettings(long offset, boolean forceTags, 58 public GpxImageCorrelationSettings(long offset, boolean forceTags, TimeSource imgTimeSource, 50 59 GpxImageDirectionPositionSettings directionPositionSettings, 51 60 GpxImageDatumSettings datumSettings) { 52 61 this.offset = offset; 53 62 this.forceTags = forceTags; 63 this.imgTimeSource = imgTimeSource; 54 64 this.directionPositionSettings = Objects.requireNonNull(directionPositionSettings); 55 65 this.datumSettings = Objects.requireNonNull(datumSettings); … … 70 80 public boolean isForceTags() { 71 81 return forceTags; 82 } 83 84 /** 85 * Return the selected image clock source, which is camera internal time, or GPS time 86 * @return the clock source 87 * @since 19426 88 */ 89 public TimeSource getImgTimeSource() { 90 return imgTimeSource; 72 91 } 73 92 … … 92 111 public String toString() { 93 112 return "[offset=" + offset + ", forceTags=" + forceTags 113 + ", clock source=" + imgTimeSource 94 114 + ", directionPositionSettings=" + directionPositionSettings 95 115 + ", datumSettings=" + datumSettings + ']'; -
trunk/src/org/openstreetmap/josm/data/gpx/GpxImageEntry.java
r19391 r19426 335 335 public boolean hasExifGpsTime() { 336 336 return exifGpsTime != null; 337 } 338 339 /** 340 * Return the time value selected with the parameter. 341 * @param timeSource the wanted time value, exifCamTime or exifGpsTime 342 * @return exifInstant or exifGpsInstant value 343 * @since 19426 344 */ 345 @Override 346 public Instant getTimeSourceInstant(TimeSource timeSource) { 347 switch (timeSource) { 348 case EXIFGPSTIME: 349 return getExifGpsInstant(); 350 case EXIFCAMTIME: 351 return getExifInstant(); 352 } 353 return null; 337 354 } 338 355 -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java
r19388 r19426 33 33 import javax.swing.AbstractAction; 34 34 import javax.swing.BorderFactory; 35 import javax.swing.ButtonGroup; 35 36 import javax.swing.DefaultComboBoxModel; 36 37 import javax.swing.JButton; … … 39 40 import javax.swing.JOptionPane; 40 41 import javax.swing.JPanel; 42 import javax.swing.JRadioButton; 41 43 import javax.swing.JSeparator; 42 44 import javax.swing.SwingConstants; … … 57 59 import org.openstreetmap.josm.data.gpx.GpxTimeOffset; 58 60 import org.openstreetmap.josm.data.gpx.GpxTimezone; 61 import org.openstreetmap.josm.data.gpx.TimeSource; 59 62 import org.openstreetmap.josm.data.gpx.WayPoint; 60 63 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; … … 89 92 private static JosmComboBoxModel<GpxDataWrapper> gpxModel; 90 93 private static boolean forceTags; 94 private static TimeSource imgTimeSource; 91 95 92 96 private final transient GeoImageLayer yLayer; … … 254 258 private JosmTextField tfTimezone; 255 259 private JosmTextField tfOffset; 260 private JRadioButton rbTimeFromCamera; 261 private JRadioButton rbTimeFromGps; 256 262 private JCheckBox cbExifImg; 257 263 private JCheckBox cbTaggedImg; … … 485 491 } 486 492 493 // CHECKSTYLE.OFF: ExecutableStatementCount 487 494 @Override 488 495 public void actionPerformed(ActionEvent ae) { … … 521 528 tfOffset.setText(delta.formatOffset()); 522 529 530 // Image Time/Clock source choice 531 rbTimeFromCamera = new JRadioButton(tr("Camera clock")); 532 rbTimeFromCamera.setSelected(true); 533 rbTimeFromGps = new JRadioButton(tr("Camera GPS clock")); 534 ButtonGroup timeSourceGroup = new ButtonGroup(); 535 timeSourceGroup.add(rbTimeFromCamera); 536 timeSourceGroup.add(rbTimeFromGps); 537 523 538 JButton buttonViewGpsPhoto = new JButton(tr("<html>Use photo of an accurate clock,<br>e.g. GPS receiver display</html>")); 524 539 buttonViewGpsPhoto.setIcon(ImageProvider.get("clock")); … … 586 601 gbc.gridx = 3; 587 602 panelTf.add(buttonAdjust, gbc); 603 604 // Image time source choice 605 gbc = GBC.eol(); 606 gbc.gridx = 0; 607 gbc.gridy = y++; 608 panelTf.add(new JLabel(tr("Image time source:")), gbc); 609 610 gbc = GBC.eol(); 611 gbc.gridx = 1; 612 gbc.gridy = y++; 613 panelTf.add(rbTimeFromCamera, gbc); 614 615 gbc = GBC.eol(); 616 gbc.gridx = 1; 617 gbc.gridy = y++; 618 panelTf.add(rbTimeFromGps, gbc); 588 619 589 620 gbc = GBC.eol().grid(0, y++).fill(GridBagConstraints.HORIZONTAL).insets(0, 12, 0, 0); … … 652 683 tfTimezone.getDocument().addDocumentListener(statusBarUpdater); 653 684 tfOffset.getDocument().addDocumentListener(statusBarUpdater); 685 rbTimeFromCamera.addItemListener(statusBarUpdaterWithRepaint); 686 rbTimeFromGps.addItemListener(statusBarUpdaterWithRepaint); 654 687 cbExifImg.addItemListener(statusBarUpdaterWithRepaint); 655 688 cbTaggedImg.addItemListener(statusBarUpdaterWithRepaint); … … 682 715 } 683 716 } 717 // CHECKSTYLE.ON: ExecutableStatementCount 684 718 685 719 public GpxImageDatumSettings getSettings() { … … 784 818 } 785 819 820 // Set image time source from the radio button status 821 if (rbTimeFromGps.isSelected()) { 822 imgTimeSource = TimeSource.EXIFGPSTIME; 823 } else { 824 imgTimeSource = TimeSource.EXIFCAMTIME; 825 } 826 786 827 // The selection of images we are about to correlate may have changed. 787 828 // So reset all images. … … 800 841 lastNumMatched = GpxImageCorrelation.matchGpxTrack(dateImgLst, selGpx.data, 801 842 pDirectionPosition.isVisible() ? 802 new GpxImageCorrelationSettings(offsetMs, forceTags, pDirectionPosition.getSettings(), 843 new GpxImageCorrelationSettings(offsetMs, forceTags, imgTimeSource, pDirectionPosition.getSettings(), 803 844 new GpxImageDatumSettings(cbAddGpsDatum.isSelected(), tfDatum.getText())) : 804 845 new GpxImageCorrelationSettings(offsetMs, forceTags)); -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/EditImagesSequenceAction.java
r18078 r19426 17 17 import org.openstreetmap.josm.data.gpx.GpxImageCorrelation; 18 18 import org.openstreetmap.josm.data.gpx.GpxImageCorrelationSettings; 19 import org.openstreetmap.josm.data.gpx.TimeSource; 19 20 import org.openstreetmap.josm.gui.ExtendedDialog; 20 21 import org.openstreetmap.josm.gui.MainApplication; … … 83 84 dateImgLst.forEach(ie -> ie.createTmp().unflagNewGpsData()); 84 85 GpxImageCorrelation.matchGpxTrack(dateImgLst, yLayer.getFauxGpxData(), 85 new GpxImageCorrelationSettings(0, false, pDirectionPosition.getSettings())); 86 new GpxImageCorrelationSettings(0, false, TimeSource.EXIFCAMTIME, pDirectionPosition.getSettings())); 86 87 yLayer.updateBufferAndRepaint(); 87 88 } -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageMetadata.java
r19391 r19426 12 12 13 13 import org.openstreetmap.josm.data.coor.ILatLon; 14 import org.openstreetmap.josm.data.gpx.TimeSource; 14 15 import org.openstreetmap.josm.data.imagery.street_level.Projections; 15 16 … … 115 116 */ 116 117 boolean hasExifGpsTime(); 118 119 /** 120 * Return the time value selected with the parameter. 121 * @param timeSource the wanted time value, exifCamTime or exifGpsTime 122 * @return exifInstant or exifGpsInstant value 123 * @since 19426 124 */ 125 Instant getTimeSourceInstant(TimeSource timeSource); 117 126 118 127 /** -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/RemoteEntry.java
r19387 r19426 18 18 19 19 import org.openstreetmap.josm.data.coor.ILatLon; 20 import org.openstreetmap.josm.data.gpx.TimeSource; 20 21 import org.openstreetmap.josm.data.imagery.street_level.IImageEntry; 21 22 import org.openstreetmap.josm.data.imagery.street_level.Projections; … … 362 363 363 364 @Override 365 public Instant getTimeSourceInstant(TimeSource timeSource) { 366 return this.getTimeSourceInstant(timeSource); 367 } 368 369 @Override 364 370 public Instant getExifGpsInstant() { 365 371 return this.exifGpsTime;
Note:
See TracChangeset
for help on using the changeset viewer.
