Changeset 29579 in osm for applications/editors/josm/plugins/measurement
- Timestamp:
- 2013-05-10T05:10:06+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementDialog.java
r29577 r29579 27 27 import org.openstreetmap.josm.tools.ImageProvider; 28 28 import org.openstreetmap.josm.tools.Shortcut; 29 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 29 30 30 31 /** … … 130 131 double area = 0.0; 131 132 Node lastNode = null; 132 for (OsmPrimitive p : newSelection) { 133 if (p instanceof Node && ((Node) p).getCoor() != null) { 134 Node n =(Node)p; 135 if (lastNode == null) { 136 lastNode = n; 137 } else { 138 length += lastNode.getCoor().greatCircleDistance(n.getCoor()); 139 segAngle = MeasurementLayer.angleBetween(lastNode.getCoor(), n.getCoor()); 140 lastNode = n; 133 // Don't mix up way and nodes computation (fix #6872). Priority given to ways 134 SubclassFilteredCollection<OsmPrimitive, Way> ways = new SubclassFilteredCollection<OsmPrimitive, Way>(newSelection, OsmPrimitive.wayPredicate); 135 if (ways.isEmpty()) { 136 for (Node n : new SubclassFilteredCollection<OsmPrimitive, Node>(newSelection, OsmPrimitive.nodePredicate)) { 137 if (n.getCoor() != null) { 138 if (lastNode == null) { 139 lastNode = n; 140 } else { 141 length += lastNode.getCoor().greatCircleDistance(n.getCoor()); 142 segAngle = MeasurementLayer.angleBetween(lastNode.getCoor(), n.getCoor()); 143 lastNode = n; 144 } 141 145 } 142 } else if (p instanceof Way) { 143 Way w = (Way)p; 146 } 147 } else { 148 for (Way w : ways) { 144 149 Node lastN = null; 145 150 double wayArea = 0.0; … … 149 154 //http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/ 150 155 wayArea += (MeasurementLayer.calcX(n.getCoor()) * MeasurementLayer.calcY(lastN.getCoor())) 151 - (MeasurementLayer.calcY(n.getCoor()) * MeasurementLayer.calcX(lastN.getCoor()));156 - (MeasurementLayer.calcY(n.getCoor()) * MeasurementLayer.calcX(lastN.getCoor())); 152 157 segAngle = MeasurementLayer.angleBetween(lastN.getCoor(), n.getCoor()); 153 158 }
Note:
See TracChangeset
for help on using the changeset viewer.