Changeset 8303 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2015-05-01T21:33:01+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r8127 r8303 688 688 */ 689 689 public static boolean isClockwise(Way w) { 690 if (!w.isClosed()) { 690 return isClockwise(w.getNodes()); 691 } 692 693 /** 694 * Determines whether path from nodes list is oriented clockwise. 695 * @see #isClockwise(Way) 696 * @param nodes Nodes list to be checked. 697 * @return true if and only if way is oriented clockwise. 698 * @throws IllegalArgumentException if way is not closed (see {@link Way#isClosed}). 699 */ 700 public static boolean isClockwise(List<Node> nodes) { 701 double area2 = 0.; 702 int nodesCount = nodes.size(); 703 if (nodesCount < 3 || nodes.get(0) != nodes.get(nodesCount - 1)) { 691 704 throw new IllegalArgumentException("Way must be closed to check orientation."); 692 705 } 693 706 694 double area2 = 0.;695 int nodesCount = w.getNodesCount();696 697 707 for (int node = 1; node <= /*sic! consider last-first as well*/ nodesCount; node++) { 698 LatLon coorPrev = w.getNode(node - 1).getCoor();699 LatLon coorCurr = w.getNode(node % nodesCount).getCoor();708 LatLon coorPrev = nodes.get(node - 1).getCoor(); 709 LatLon coorCurr = nodes.get(node % nodesCount).getCoor(); 700 710 area2 += coorPrev.lon() * coorCurr.lat(); 701 711 area2 -= coorCurr.lon() * coorPrev.lat();
Note:
See TracChangeset
for help on using the changeset viewer.