source: josm/trunk/src/org/openstreetmap/josm/data/gpx/GpxDistance.java@ 15390

Last change on this file since 15390 was 15390, checked in by Don-vip, 7 years ago

remove deprecated code

  • Property svn:eol-style set to native
File size: 1.0 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.gpx;
3
4import org.openstreetmap.josm.data.osm.Node;
5import org.openstreetmap.josm.data.osm.OsmPrimitive;
6import org.openstreetmap.josm.tools.Geometry;
7
8/**
9 * A class to find the distance between an {@link OsmPrimitive} and a GPX point.
10 *
11 * @author Taylor Smock
12 * @since 14802
13 */
14public final class GpxDistance {
15 private GpxDistance() {
16 // This class should not be instantiated
17 }
18
19 /**
20 * Find the distance between a point and a dataset of surveyed points
21 * @param p OsmPrimitive from which to get the lowest distance to a GPX point
22 * @param gpxData Data from which to get the GPX points
23 * @return The shortest distance
24 */
25 public static double getLowestDistance(OsmPrimitive p, GpxData gpxData) {
26 return gpxData.getTrackPoints()
27 .mapToDouble(tp -> Geometry.getDistance(p, new Node(tp.getCoor())))
28 .filter(x -> x >= 0)
29 .min().orElse(Double.MAX_VALUE);
30 }
31}
Note: See TracBrowser for help on using the repository browser.