Changeset 1724 in josm for trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java
- Timestamp:
- 2009-07-03T22:19:22+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java
r1722 r1724 84 84 for (WayPoint wpt : waypoints) { 85 85 if (bounds == null) { 86 bounds = new Bounds(wpt. latlon, wpt.latlon);86 bounds = new Bounds(wpt.getCoor()); 87 87 } else { 88 bounds.extend(wpt. latlon);88 bounds.extend(wpt.getCoor()); 89 89 } 90 90 } … … 92 92 for (WayPoint wpt : rte.routePoints) { 93 93 if (bounds == null) { 94 bounds = new Bounds(wpt. latlon, wpt.latlon);94 bounds = new Bounds(wpt.getCoor()); 95 95 } else { 96 bounds.extend(wpt. latlon);96 bounds.extend(wpt.getCoor()); 97 97 } 98 98 } … … 102 102 for (WayPoint wpt : trkseg) { 103 103 if (bounds == null) { 104 bounds = new Bounds(wpt. latlon, wpt.latlon);104 bounds = new Bounds(wpt.getCoor()); 105 105 } else { 106 bounds.extend(wpt. latlon);106 bounds.extend(wpt.getCoor()); 107 107 } 108 108 } … … 123 123 for (WayPoint tpt : trkseg) { 124 124 if(last != null){ 125 result += calcDistance(last.latlon, tpt.latlon);125 result += last.getCoor().greatCircleDistance(tpt.getCoor()); 126 126 } 127 127 last = tpt; … … 132 132 return result; 133 133 } 134 135 /**136 * returns the distance in meters between two LatLons137 */138 public static double calcDistance(LatLon p1, LatLon p2){139 double lat1, lon1, lat2, lon2;140 double dlon, dlat;141 142 lat1 = p1.lat() * Math.PI / 180.0;143 lon1 = p1.lon() * Math.PI / 180.0;144 lat2 = p2.lat() * Math.PI / 180.0;145 lon2 = p2.lon() * Math.PI / 180.0;146 147 dlon = lon2 - lon1;148 dlat = lat2 - lat1;149 150 double a = (Math.pow(Math.sin(dlat/2), 2) + Math.cos(lat1) * Math.cos(lat2) * Math.pow(Math.sin(dlon/2), 2));151 double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));152 return 6367000 * c;153 }154 155 134 }
Note:
See TracChangeset
for help on using the changeset viewer.