Changeset 35978 in osm for applications/editors/josm/plugins/measurement/src/org/openstreetmap
- Timestamp:
- 2022-06-15T20:10:48+02:00 (3 years ago)
- Location:
- applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementDialog.java
r35976 r35978 204 204 } else { 205 205 for (Node n : nodes) { 206 if (n. getCoor() != null) {206 if (n.isLatLonKnown()) { 207 207 if (lastNode == null) { 208 208 lastNode = n; 209 209 } else { 210 length += lastNode.g etCoor().greatCircleDistance(n.getCoor());210 length += lastNode.greatCircleDistance(n); 211 211 segAngle = MeasurementLayer.angleBetween(lastNode, n); 212 212 lastNode = n; … … 223 223 boolean isCircle = true; 224 224 for (Node n: w.getNodes()) { 225 if (lastN != null && lastN. getCoor() != null && n.getCoor() != null) {226 final double segLength = lastN.g etCoor().greatCircleDistance(n.getCoor());225 if (lastN != null && lastN.isLatLonKnown() && n.isLatLonKnown()) { 226 final double segLength = lastN.greatCircleDistance(n); 227 227 if (firstSegLength == null) { 228 228 firstSegLength = segLength; … … 233 233 length += segLength; 234 234 //http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/ 235 wayArea += (MeasurementLayer.calcX(n .getCoor()) * MeasurementLayer.calcY(lastN.getCoor()))236 - (MeasurementLayer.calcY(n .getCoor()) * MeasurementLayer.calcX(lastN.getCoor()));235 wayArea += (MeasurementLayer.calcX(n) * MeasurementLayer.calcY(lastN)) 236 - (MeasurementLayer.calcY(n) * MeasurementLayer.calcX(lastN)); 237 237 segAngle = MeasurementLayer.angleBetween(lastN, n); 238 238 } -
applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementLayer.java
r35976 r35978 157 157 * https://stackoverflow.com/questions/4681737/how-to-calculate-the-area-of-a-polygon-on-the-earths-surface-using-python 158 158 */ 159 public static double calcX(LatLon p1){ 159 public static double calcX(ILatLon p1){ 160 160 return p1.lat() * Math.PI * 6367000 / 180; 161 161 } 162 162 163 public static double calcY(LatLon p1){ 163 public static double calcY(ILatLon p1){ 164 164 return p1.lon() * ( Math.PI * 6367000 / 180) * Math.cos(p1.lat() * Math.PI / 180); 165 165 } 166 166 167 167 public static double calcDistance(WayPoint p1, WayPoint p2){ 168 return p1.g etCoor().greatCircleDistance(p2.getCoor());168 return p1.greatCircleDistance(p2); 169 169 } 170 170
Note:
See TracChangeset
for help on using the changeset viewer.