+ private double dist(AltosLatLon lat_lon, AltosMapPathPoint point) {
+ return (new AltosGreatCircle(lat_lon.lat,
+ lat_lon.lon,
+ point.gps.lat,
+ point.gps.lon)).distance;
+ }
+
+ public AltosMapPathPoint nearest(AltosLatLon lat_lon) {
+ AltosMapPathPoint nearest = null;
+ double nearest_dist = 0;
+ for (AltosMapPathPoint point : points) {
+ if (nearest == null) {
+ nearest = point;
+ nearest_dist = dist(lat_lon, point);
+ } else {
+ double d = dist(lat_lon, point);
+ if (d < nearest_dist) {
+ nearest = point;
+ nearest_dist = d;
+ }
+ }
+ }
+ return nearest;
+ }
+