diff --git a/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java b/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java
index 67c00a8735..d6c9b0b07b 100644
|
a
|
b
|
public class CorrelateGpxWithImages extends AbstractAction implements ExpertMode
|
| 551 | 551 | |
| 552 | 552 | JLabel labelPosition = new JLabel(tr("Override position for: ")); |
| 553 | 553 | |
| 554 | | int numAll = yLayer.getSortedImgList(true, true).size(); |
| 555 | | int numExif = numAll - yLayer.getSortedImgList(false, true).size(); |
| 556 | | int numTagged = numAll - yLayer.getSortedImgList(true, false).size(); |
| | 554 | int numAll = yLayer.getSortedImgList(true, true, imgTimeSource).size(); |
| | 555 | int numExif = numAll - yLayer.getSortedImgList(false, true, imgTimeSource).size(); |
| | 556 | int numTagged = numAll - yLayer.getSortedImgList(true, false, imgTimeSource).size(); |
| 557 | 557 | |
| 558 | 558 | cbExifImg = new JCheckBox(tr("Images with geo location in exif data ({0}/{1})", numExif, numAll)); |
| 559 | 559 | cbExifImg.setEnabled(numExif != 0); |
| … |
… |
public class CorrelateGpxWithImages extends AbstractAction implements ExpertMode
|
| 828 | 828 | // So reset all images. |
| 829 | 829 | yLayer.discardTmp(); |
| 830 | 830 | |
| | 831 | //Get how many images are present in the layer |
| | 832 | int totalImg = yLayer.getImages().size(); |
| | 833 | |
| 831 | 834 | // Construct a list of images that have a date, and sort them on the date. |
| 832 | 835 | List<ImageEntry> dateImgLst = getSortedImgList(); |
| 833 | 836 | // Create a temporary copy for each image |
| … |
… |
public class CorrelateGpxWithImages extends AbstractAction implements ExpertMode
|
| 846 | 849 | |
| 847 | 850 | return trn("<html>Matched <b>{0}</b> of <b>{1}</b> photo to GPX track.</html>", |
| 848 | 851 | "<html>Matched <b>{0}</b> of <b>{1}</b> photos to GPX track.</html>", |
| 849 | | dateImgLst.size(), lastNumMatched, dateImgLst.size()); |
| | 852 | totalImg, lastNumMatched, totalImg); |
| 850 | 853 | } |
| 851 | 854 | } |
| 852 | 855 | |
| … |
… |
public class CorrelateGpxWithImages extends AbstractAction implements ExpertMode
|
| 1003 | 1006 | } |
| 1004 | 1007 | |
| 1005 | 1008 | private List<ImageEntry> getSortedImgList() { |
| 1006 | | return yLayer.getSortedImgList(cbExifImg.isSelected(), cbTaggedImg.isSelected()); |
| | 1009 | return yLayer.getSortedImgList(cbExifImg.isSelected(), cbTaggedImg.isSelected(), imgTimeSource); |
| 1007 | 1010 | } |
| 1008 | 1011 | |
| 1009 | 1012 | private static GpxDataWrapper selectedGPX(boolean complain) { |
diff --git a/src/org/openstreetmap/josm/gui/layer/geoimage/EditImagesSequenceAction.java b/src/org/openstreetmap/josm/gui/layer/geoimage/EditImagesSequenceAction.java
index 6d84ef2310..7f4dfa593b 100644
|
a
|
b
|
public class EditImagesSequenceAction extends JosmAction {
|
| 79 | 79 | // So reset all images. |
| 80 | 80 | yLayer.discardTmp(); |
| 81 | 81 | // Construct a list of images that have a date, and sort them on the date. |
| 82 | | List<ImageEntry> dateImgLst = yLayer.getSortedImgList(true, true); |
| | 82 | List<ImageEntry> dateImgLst = yLayer.getSortedImgList(true, true, TimeSource.EXIFCAMTIME); |
| 83 | 83 | // Create a temporary copy for each image |
| 84 | 84 | dateImgLst.forEach(ie -> ie.createTmp().unflagNewGpsData()); |
| 85 | 85 | GpxImageCorrelation.matchGpxTrack(dateImgLst, yLayer.getFauxGpxData(), |
diff --git a/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java b/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
index da00f78db7..ce29dd6444 100644
|
a
|
b
|
import org.openstreetmap.josm.data.ImageData.ImageDataUpdateListener;
|
| 47 | 47 | import org.openstreetmap.josm.data.gpx.GpxData; |
| 48 | 48 | import org.openstreetmap.josm.data.gpx.GpxImageEntry; |
| 49 | 49 | import org.openstreetmap.josm.data.gpx.GpxTrack; |
| | 50 | import org.openstreetmap.josm.data.gpx.TimeSource; |
| 50 | 51 | import org.openstreetmap.josm.data.imagery.street_level.IImageEntry; |
| 51 | 52 | import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; |
| 52 | 53 | import org.openstreetmap.josm.data.preferences.NamedColorProperty; |
| … |
… |
public class GeoImageLayer extends AbstractModifiableLayer implements
|
| 977 | 978 | * Default setting is to return untagged images, but may be overwritten. |
| 978 | 979 | * @param exif also returns images with exif-gps info |
| 979 | 980 | * @param tagged also returns tagged images |
| | 981 | * @param gpsTime use GPS Time if true, instead of Camera RTC Time |
| 980 | 982 | * @return matching images |
| | 983 | * @since xxx gpsTime was added |
| 981 | 984 | */ |
| 982 | | List<ImageEntry> getSortedImgList(boolean exif, boolean tagged) { |
| | 985 | List<ImageEntry> getSortedImgList(boolean exif, boolean tagged, TimeSource timeSource) { |
| 983 | 986 | return data.getImages().stream() |
| 984 | | .filter(GpxImageEntry::hasExifTime) |
| | 987 | .filter(timeSource == TimeSource.EXIFGPSTIME ? GpxImageEntry::hasExifGpsTime : GpxImageEntry::hasExifTime) |
| 985 | 988 | .filter(e -> e.getExifCoor() == null || exif) |
| 986 | 989 | .filter(e -> tagged || !e.isTagged() || e.getExifCoor() != null) |
| 987 | | .sorted(Comparator.comparing(ImageEntry::getExifInstant)) |
| | 990 | .sorted(timeSource == TimeSource.EXIFGPSTIME |
| | 991 | ? Comparator.comparing(ImageEntry::getExifGpsInstant) |
| | 992 | : Comparator.comparing(ImageEntry::getExifInstant)) |
| 988 | 993 | .collect(toList()); |
| 989 | 994 | } |
| 990 | 995 | } |
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayerTest.java
index 549de9c44b..454fbf46a4 100644
|
a
|
b
|
|
| 2 | 2 | package org.openstreetmap.josm.gui.layer.geoimage; |
| 3 | 3 | |
| 4 | 4 | import static org.junit.jupiter.api.Assertions.assertThrows; |
| | 5 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 5 | 6 | |
| | 7 | import java.util.Arrays; |
| 6 | 8 | import java.util.Collections; |
| 7 | 9 | |
| 8 | 10 | import org.junit.jupiter.api.AfterEach; |
| 9 | 11 | import org.junit.jupiter.api.Test; |
| | 12 | import org.openstreetmap.josm.data.gpx.TimeSource; |
| 10 | 13 | import org.openstreetmap.josm.data.osm.DataSet; |
| 11 | 14 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
| 12 | 15 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 13 | 16 | import org.openstreetmap.josm.testutils.annotations.Main; |
| 14 | 17 | import org.openstreetmap.josm.testutils.annotations.ThreadSync; |
| | 18 | import org.openstreetmap.josm.tools.date.DateUtils; |
| 15 | 19 | |
| 16 | 20 | /** |
| 17 | 21 | * Unit tests of {@link GeoImageLayer} class. |
| … |
… |
class GeoImageLayerTest {
|
| 41 | 45 | OsmDataLayer osmDataLayer = new OsmDataLayer(new DataSet(), "", null); |
| 42 | 46 | assertThrows(IllegalArgumentException.class, () -> geoImageLayer.mergeFrom(osmDataLayer)); |
| 43 | 47 | } |
| | 48 | |
| | 49 | /** |
| | 50 | * Test that {@link GeoImageLayer#getSortedImgList} filters images without ExifGpsTime |
| | 51 | */ |
| | 52 | @Test |
| | 53 | void testMissingGPSTimeStamp() { |
| | 54 | ImageEntry i1, i2; |
| | 55 | i1 = new ImageEntry(); |
| | 56 | i1.setExifGpsTime(DateUtils.parseInstant("2016:01:03 12:00:00")); |
| | 57 | i2 = new ImageEntry(); |
| | 58 | i2.setExifTime(DateUtils.parseInstant("2016:01:03 12:00:01")); |
| | 59 | |
| | 60 | GeoImageLayer geoGpsImageLayer = new GeoImageLayer(Arrays.asList(i1, i2), null); |
| | 61 | assertEquals(1, geoGpsImageLayer.getSortedImgList(false, false, TimeSource.EXIFGPSTIME).size()); |
| | 62 | } |
| | 63 | |
| 44 | 64 | } |