Changeset 14802 in josm
- Timestamp:
- 2019-02-23T17:46:51+01:00 (6 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/MainLayerManager.java
r14156 r14802 13 13 import javax.swing.JOptionPane; 14 14 15 import org.openstreetmap.josm.data.gpx.GpxData; 15 16 import org.openstreetmap.josm.data.osm.DataSet; 16 17 import org.openstreetmap.josm.data.osm.OsmData; 17 18 import org.openstreetmap.josm.gui.MainApplication; 18 19 import org.openstreetmap.josm.gui.io.AsynchronousUploadPrimitivesTask; 20 import org.openstreetmap.josm.gui.layer.geoimage.GeoImageLayer; 19 21 import org.openstreetmap.josm.gui.util.GuiHelper; 20 22 import org.openstreetmap.josm.tools.Logging; … … 542 544 } 543 545 } 546 547 /** 548 * Returns all {@link GpxData} we can get from current layers. 549 * @return all {@code GpxData} we can get from current layers 550 * @since 14802 551 */ 552 public List<GpxData> getAllGpxData() { 553 List<GpxData> result = new ArrayList<>(); 554 for (Layer layer : getLayers()) { 555 if (layer instanceof GpxLayer) { 556 result.add(((GpxLayer) layer).data); 557 } else if (layer instanceof GeoImageLayer) { 558 result.add(((GeoImageLayer) layer).getFauxGpxLayer().data); 559 } 560 } 561 return result; 562 } 544 563 } -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
r14615 r14802 43 43 import org.openstreetmap.josm.data.ImageData; 44 44 import org.openstreetmap.josm.data.ImageData.ImageDataUpdateListener; 45 import org.openstreetmap.josm.data.gpx.GpxData; 46 import org.openstreetmap.josm.data.gpx.WayPoint; 45 47 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 46 48 import org.openstreetmap.josm.gui.MainApplication; … … 76 78 private final ImageData data; 77 79 GpxLayer gpxLayer; 80 GpxLayer gpxFauxLayer; 78 81 79 82 private final Icon icon = ImageProvider.get("dialogs/geoimage/photo-marker"); … … 925 928 } 926 929 930 /** 931 * Returns a faux GPX layer built from the images or the associated GPX layer. 932 * @return A faux GPX layer or the associated GPX layer 933 * @since 14802 934 */ 935 public synchronized GpxLayer getFauxGpxLayer() { 936 if (gpxLayer != null) return getGpxLayer(); 937 if (gpxFauxLayer == null) { 938 GpxData gpxData = new GpxData(); 939 List<ImageEntry> imageList = data.getImages(); 940 for (ImageEntry image : imageList) { 941 WayPoint twaypoint = new WayPoint(image.getPos()); 942 gpxData.addWaypoint(twaypoint); 943 } 944 gpxFauxLayer = new GpxLayer(gpxData); 945 } 946 return gpxFauxLayer; 947 } 948 927 949 @Override 928 950 public void jumpToNextMarker() { -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java
r14484 r14802 25 25 26 26 import org.openstreetmap.josm.data.coor.LatLon; 27 import org.openstreetmap.josm.data.gpx.GpxDistance; 27 28 import org.openstreetmap.josm.data.osm.IPrimitive; 28 29 import org.openstreetmap.josm.data.osm.Node; 30 import org.openstreetmap.josm.data.osm.OsmPrimitive; 29 31 import org.openstreetmap.josm.data.osm.Way; 30 32 import org.openstreetmap.josm.data.osm.search.SearchCompiler; 31 33 import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match; 32 34 import org.openstreetmap.josm.data.osm.search.SearchParseError; 35 import org.openstreetmap.josm.gui.MainApplication; 33 36 import org.openstreetmap.josm.gui.mappaint.Cascade; 34 37 import org.openstreetmap.josm.gui.mappaint.Environment; … … 520 523 521 524 /** 525 * Returns the lowest distance between the OSM object and a GPX point 526 * <p> 527 * @param env the environment 528 * @return the distance between the object and the closest gpx point or {@code Double.MAX_VALUE} 529 * @since 14802 530 */ 531 public static double gpx_distance(final Environment env) { // NO_UCD (unused code) 532 if (env.osm instanceof OsmPrimitive) { 533 return MainApplication.getLayerManager().getAllGpxData().stream() 534 .mapToDouble(gpx -> GpxDistance.getLowestDistance((OsmPrimitive) env.osm, gpx)) 535 .min().orElse(Double.MAX_VALUE); 536 } 537 return Double.MAX_VALUE; 538 } 539 540 /** 522 541 * Determines whether the object has a tag with the given key. 523 542 * @param env the environment
Note:
See TracChangeset
for help on using the changeset viewer.