Changeset 12161 in josm for trunk/src/org/openstreetmap/josm/tools/Geometry.java
- Timestamp:
- 2017-05-15T15:43:30+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r11779 r12161 22 22 import org.openstreetmap.josm.command.Command; 23 23 import org.openstreetmap.josm.data.coor.EastNorth; 24 import org.openstreetmap.josm.data.coor.LatLon;25 24 import org.openstreetmap.josm.data.osm.BBox; 26 25 import org.openstreetmap.josm.data.osm.DataSet; … … 224 223 BBox bounds = new BBox(nodes.get(0)); 225 224 for (Node n: nodes) { 226 bounds.add(n .getCoor());225 bounds.add(n); 227 226 } 228 227 return bounds; … … 417 416 return p2; 418 417 else 419 return new EastNorth(p1.getX() + ldx * offset, p1.getY() + ldy *offset);418 return p1.interpolate(p2, offset); 420 419 } 421 420 … … 513 512 for (Node n : polygon) { 514 513 if (begin) { 515 path.moveTo(n. getCoor().lon(), n.getCoor().lat());514 path.moveTo(n.lon(), n.lat()); 516 515 begin = false; 517 516 } else { 518 path.lineTo(n. getCoor().lon(), n.getCoor().lat());517 path.lineTo(n.lon(), n.lat()); 519 518 } 520 519 } … … 728 727 729 728 for (int node = 1; node <= /*sic! consider last-first as well*/ nodesCount; node++) { 730 LatLon coorPrev = nodes.get(node - 1).getCoor();731 LatLon coorCurr = nodes.get(node % nodesCount).getCoor();729 Node coorPrev = nodes.get(node - 1); 730 Node coorCurr = nodes.get(node % nodesCount); 732 731 area2 += coorPrev.lon() * coorCurr.lat(); 733 732 area2 -= coorCurr.lon() * coorPrev.lat(); … … 988 987 double area = 0; 989 988 double perimeter = 0; 989 Projection useProjection = projection == null ? Main.getProjection() : projection; 990 990 991 if (!nodes.isEmpty()) { 991 992 boolean closed = nodes.get(0) == nodes.get(nodes.size() - 1); 992 993 int numSegments = closed ? nodes.size() - 1 : nodes.size(); 993 EastNorth p1 = projection == null ? nodes.get(0).getEastNorth() : projection.latlon2eastNorth(nodes.get(0).getCoor());994 EastNorth p1 = nodes.get(0).getEastNorth(useProjection); 994 995 for (int i = 1; i <= numSegments; i++) { 995 996 final Node node = nodes.get(i == numSegments ? 0 : i); 996 final EastNorth p2 = projection == null ? node.getEastNorth() : projection.latlon2eastNorth(node.getCoor());997 final EastNorth p2 = node.getEastNorth(useProjection); 997 998 if (p1 != null && p2 != null) { 998 999 area += p1.east() * p2.north() - p2.east() * p1.north();
Note:
See TracChangeset
for help on using the changeset viewer.