Changeset 18065 in josm
- Timestamp:
- 2021-07-18T15:40:42+02:00 (3 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/gpx/GpxImageCorrelation.java
r18061 r18065 26 26 27 27 /** 28 * Match a list of photos to a gpx track with a given offset.28 * Match a list of photos to a gpx track with given settings. 29 29 * All images need a exifTime attribute and the List must be sorted according to these times. 30 30 * @param images images to match … … 35 35 public static int matchGpxTrack(List<? extends GpxImageEntry> images, GpxData selectedGpx, GpxImageCorrelationSettings settings) { 36 36 int ret = 0; 37 38 if (Logging.isDebugEnabled()) { 39 Logging.debug("Correlating {0} images to {1} GPX track segments using {2}", 40 images.size(), selectedGpx.getTrackSegsCount(), settings); 41 } 37 42 38 43 boolean trkInt, trkTag, segInt, segTag; … … 73 78 WayPoint prevWp = null; 74 79 75 for (List<List<WayPoint>> segs : loadTracks(selectedGpx. tracks)) {80 for (List<List<WayPoint>> segs : loadTracks(selectedGpx.getTracks())) { 76 81 boolean firstSegment = true; 77 82 for (List<WayPoint> wps : segs) { -
trunk/src/org/openstreetmap/josm/data/gpx/GpxImageCorrelationSettings.java
r18061 r18065 59 59 return directionPositionSettings; 60 60 } 61 62 @Override 63 public String toString() { 64 return "[offset=" + offset + ", forceTags=" + forceTags 65 + ", directionPositionSettings=" + directionPositionSettings + ']'; 66 } 61 67 } -
trunk/src/org/openstreetmap/josm/data/gpx/GpxImageDirectionPositionSettings.java
r18061 r18065 70 70 return elevationShift; 71 71 } 72 73 @Override 74 public String toString() { 75 return "[setImageDirection=" + setImageDirection 76 + ", imageDirectionAngleOffset=" + imageDirectionAngleOffset + ", shiftImageX=" + shiftImageX 77 + ", shiftImageY=" + shiftImageY + ", elevationShift=" + elevationShift + ']'; 78 } 72 79 } -
trunk/src/org/openstreetmap/josm/data/gpx/GpxImageEntry.java
r18014 r18065 11 11 import java.util.Locale; 12 12 import java.util.Objects; 13 import java.util.Optional; 13 14 import java.util.function.Consumer; 14 15 … … 512 513 * {@link #applyTmp()} or {@link #discardTmp()} if the temporary variable 513 514 * is not needed anymore. 514 */ 515 public void createTmp() { 515 * @return the fresh copy. 516 */ 517 public GpxImageEntry createTmp() { 516 518 tmp = new GpxImageEntry(this); 517 519 tmp.tmp = null; 520 return tmp; 518 521 } 519 522 … … 765 768 } 766 769 } 770 771 /** 772 * Returns a {@link WayPoint} representation of this GPX image entry. 773 * @return a {@code WayPoint} representation of this GPX image entry (containing position, instant and elevation) 774 * @since 18065 775 */ 776 public WayPoint asWayPoint() { 777 CachedLatLon position = getPos(); 778 WayPoint wpt = null; 779 if (position != null) { 780 wpt = new WayPoint(position); 781 wpt.setInstant(Optional.ofNullable(exifGpsTime).orElse(exifTime)); 782 Double ele = getElevation(); 783 if (ele != null) { 784 wpt.put(GpxConstants.PT_ELE, ele.toString()); 785 } 786 } 787 return wpt; 788 } 767 789 } -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java
r18061 r18065 24 24 import java.io.File; 25 25 import java.text.ParseException; 26 import java.util.Comparator;27 26 import java.util.List; 27 import java.util.Objects; 28 28 import java.util.TimeZone; 29 29 import java.util.concurrent.TimeUnit; 30 30 import java.util.function.Consumer; 31 import java.util.stream.Collectors;32 31 33 32 import javax.swing.AbstractAction; … … 52 51 import org.openstreetmap.josm.data.gpx.GpxImageCorrelation; 53 52 import org.openstreetmap.josm.data.gpx.GpxImageCorrelationSettings; 54 import org.openstreetmap.josm.data.gpx.GpxImageEntry;55 53 import org.openstreetmap.josm.data.gpx.GpxTimeOffset; 56 54 import org.openstreetmap.josm.data.gpx.GpxTimezone; … … 152 150 case CANCEL: 153 151 if (yLayer != null) { 154 for (ImageEntry ie : yLayer.getImageData().getImages()) { 155 ie.discardTmp(); 156 } 152 yLayer.discardTmp(); 157 153 yLayer.updateBufferAndRepaint(); 158 154 } … … 188 184 } 189 185 190 for (ImageEntry ie : yLayer.getImageData().getImages()) { 191 ie.applyTmp(); 192 } 193 186 yLayer.applyTmp(); 194 187 yLayer.updateBufferAndRepaint(); 195 188 196 189 break; 197 190 default: 198 throw new IllegalStateException( );191 throw new IllegalStateException(Integer.toString(result)); 199 192 } 200 193 } … … 469 462 JLabel labelPosition = new JLabel(tr("Override position for: ")); 470 463 471 int numAll = getSortedImgList(true, true).size();472 int numExif = numAll - getSortedImgList(false, true).size();473 int numTagged = numAll - getSortedImgList(true, false).size();464 int numAll = yLayer.getSortedImgList(true, true).size(); 465 int numExif = numAll - yLayer.getSortedImgList(false, true).size(); 466 int numTagged = numAll - yLayer.getSortedImgList(true, false).size(); 474 467 475 468 cbExifImg = new JCheckBox(tr("Images with geo location in exif data ({0}/{1})", numExif, numAll)); … … 581 574 statusBar.add(statusBarText); 582 575 583 RepaintTheMapListener repaintTheMap = new RepaintTheMapListener( );576 RepaintTheMapListener repaintTheMap = new RepaintTheMapListener(yLayer); 584 577 pDirectionPosition.addFocusListenerOnComponent(repaintTheMap); 585 578 tfTimezone.addFocusListener(repaintTheMap); … … 703 696 // The selection of images we are about to correlate may have changed. 704 697 // So reset all images. 705 for (ImageEntry ie: yLayer.getImageData().getImages()) { 706 ie.discardTmp(); 707 } 698 yLayer.discardTmp(); 708 699 709 700 // Construct a list of images that have a date, and sort them on the date. 710 701 List<ImageEntry> dateImgLst = getSortedImgList(); 711 702 // Create a temporary copy for each image 712 dateImgLst.forEach(ie -> { 713 ie.createTmp(); 714 ie.getTmp().unflagNewGpsData(); 715 }); 703 dateImgLst.forEach(ie -> ie.createTmp().unflagNewGpsData()); 716 704 717 705 GpxDataWrapper selGpx = selectedGPX(false); … … 731 719 } 732 720 733 private class RepaintTheMapListener implements FocusListener { 721 static class RepaintTheMapListener implements FocusListener { 722 723 private final GeoImageLayer yLayer; 724 725 RepaintTheMapListener(GeoImageLayer yLayer) { 726 this.yLayer = Objects.requireNonNull(yLayer); 727 } 728 734 729 @Override 735 730 public void focusGained(FocusEvent e) { // do nothing … … 877 872 878 873 private List<ImageEntry> getSortedImgList() { 879 return getSortedImgList(cbExifImg.isSelected(), cbTaggedImg.isSelected()); 880 } 881 882 /** 883 * Returns a list of images that fulfill the given criteria. 884 * Default setting is to return untagged images, but may be overwritten. 885 * @param exif also returns images with exif-gps info 886 * @param tagged also returns tagged images 887 * @return matching images 888 */ 889 private List<ImageEntry> getSortedImgList(boolean exif, boolean tagged) { 890 return yLayer.getImageData().getImages().stream() 891 .filter(GpxImageEntry::hasExifTime) 892 .filter(e -> e.getExifCoor() == null || exif) 893 .filter(e -> tagged || !e.isTagged() || e.getExifCoor() != null) 894 .sorted(Comparator.comparing(ImageEntry::getExifInstant)) 895 .collect(Collectors.toList()); 874 return yLayer.getSortedImgList(cbExifImg.isSelected(), cbTaggedImg.isSelected()); 896 875 } 897 876 -
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.