Changeset 18065 in josm for trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
- Timestamp:
- 2021-07-18T15:40:42+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
r18035 r18065 2 2 package org.openstreetmap.josm.gui.layer.geoimage; 3 3 4 import static java.util.stream.Collectors.toList; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import static org.openstreetmap.josm.tools.I18n.trn; … … 21 22 import java.io.File; 22 23 import java.util.ArrayList; 24 import java.util.Arrays; 23 25 import java.util.Collection; 26 import java.util.Collections; 27 import java.util.Comparator; 24 28 import java.util.LinkedList; 25 29 import java.util.List; 30 import java.util.Objects; 26 31 import java.util.concurrent.ExecutorService; 27 32 import java.util.concurrent.Executors; … … 31 36 32 37 import org.openstreetmap.josm.actions.AutoScaleAction; 38 import org.openstreetmap.josm.actions.ExpertToggleAction; 33 39 import org.openstreetmap.josm.actions.RenameLayerAction; 34 40 import org.openstreetmap.josm.actions.mapmode.MapMode; … … 40 46 import org.openstreetmap.josm.data.ImageData.ImageDataUpdateListener; 41 47 import org.openstreetmap.josm.data.gpx.GpxData; 42 import org.openstreetmap.josm.data.gpx.WayPoint; 48 import org.openstreetmap.josm.data.gpx.GpxImageEntry; 49 import org.openstreetmap.josm.data.gpx.GpxTrack; 43 50 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 44 51 import org.openstreetmap.josm.gui.MainApplication; … … 72 79 GpxLayer gpxLayer; 73 80 GpxLayer gpxFauxLayer; 81 GpxData gpxFauxData; 74 82 75 83 private CorrelateGpxWithImages gpxCorrelateAction; … … 247 255 entries.add(SeparatorLayerAction.INSTANCE); 248 256 entries.add(getGpxCorrelateAction()); 257 if (ExpertToggleAction.isExpert()) { 258 entries.add(new EditImagesSequenceAction(this)); 259 } 249 260 entries.add(new ShowThumbnailAction(this)); 250 261 if (!menuAdditions.isEmpty()) { … … 807 818 if (gpxLayer != null) return getGpxLayer(); 808 819 if (gpxFauxLayer == null) { 809 GpxData gpxData = new GpxData(); 810 for (ImageEntry image : data.getImages()) { 811 gpxData.addWaypoint(new WayPoint(image.getPos())); 812 } 813 gpxFauxLayer = new GpxLayer(gpxData); 820 gpxFauxLayer = new GpxLayer(getFauxGpxData()); 814 821 } 815 822 return gpxFauxLayer; 823 } 824 825 /** 826 * Returns a faux GPX data built from the images or the associated GPX layer data. 827 * @return A faux GPX data or the associated GPX layer data 828 * @since 18065 829 */ 830 public synchronized GpxData getFauxGpxData() { 831 if (gpxLayer != null) return getGpxLayer().data; 832 if (gpxFauxData == null) { 833 gpxFauxData = new GpxData(); 834 gpxFauxData.addTrack(new GpxTrack(Arrays.asList( 835 data.getImages().stream().map(ImageEntry::asWayPoint).filter(Objects::nonNull).collect(toList())), 836 Collections.emptyMap())); 837 } 838 return gpxFauxData; 816 839 } 817 840 … … 870 893 return data; 871 894 } 895 896 void applyTmp() { 897 data.getImages().forEach(ImageEntry::applyTmp); 898 } 899 900 void discardTmp() { 901 data.getImages().forEach(ImageEntry::discardTmp); 902 } 903 904 /** 905 * Returns a list of images that fulfill the given criteria. 906 * Default setting is to return untagged images, but may be overwritten. 907 * @param exif also returns images with exif-gps info 908 * @param tagged also returns tagged images 909 * @return matching images 910 */ 911 List<ImageEntry> getSortedImgList(boolean exif, boolean tagged) { 912 return data.getImages().stream() 913 .filter(GpxImageEntry::hasExifTime) 914 .filter(e -> e.getExifCoor() == null || exif) 915 .filter(e -> tagged || !e.isTagged() || e.getExifCoor() != null) 916 .sorted(Comparator.comparing(ImageEntry::getExifInstant)) 917 .collect(toList()); 918 } 872 919 }
Note:
See TracChangeset
for help on using the changeset viewer.
