Changeset 7193 in josm for trunk/src/org/openstreetmap/josm/tools
 Timestamp:
 20140530T10:27:18+02:00 (9 years ago)
 Location:
 trunk/src/org/openstreetmap/josm/tools
 Files:

 2 added
 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/org/openstreetmap/josm/tools/Geometry.java
r7145 r7193 444 444 /** 445 445 * Returns the Area of a polygon, from its list of nodes. 446 * @param polygon List of nodes forming polygon 446 * @param polygon List of nodes forming polygon (EastNorth coordinates) 447 447 * @return Area for the given list of nodes 448 448 * @since 6841 … … 469 469 return new Area(path); 470 470 } 471 472 /** 473 * Returns the Area of a polygon, from its list of nodes. 474 * @param polygon List of nodes forming polygon (LatLon coordinates) 475 * @return Area for the given list of nodes 476 * @since 6841 477 */ 478 public static Area getAreaLatLon(List<Node> polygon) { 479 Path2D path = new Path2D.Double(); 480 481 boolean begin = true; 482 for (Node n : polygon) { 483 if (begin) { 484 path.moveTo(n.getCoor().lon(), n.getCoor().lat()); 485 begin = false; 486 } else { 487 path.lineTo(n.getCoor().lon(), n.getCoor().lat()); 488 } 489 } 490 if (!begin) { 491 path.closePath(); 492 } 493 494 return new Area(path); 495 } 471 496 472 497 /** … … 490 515 */ 491 516 public static PolygonIntersection polygonIntersection(Area a1, Area a2) { 517 return polygonIntersection(a1, a2, 1.0); 518 } 519 520 /** 521 * Tests if two polygons intersect. 522 * @param a1 Area of first polygon 523 * @param a2 Area of second polygon 524 * @param eps an area threshold, everything below is considered an empty intersection 525 * @return intersection kind 526 */ 527 public static PolygonIntersection polygonIntersection(Area a1, Area a2, double eps) { 492 528 493 529 Area inter = new Area(a1); … … 496 532 Rectangle bounds = inter.getBounds(); 497 533 498 if (inter.isEmpty()  bounds.getHeight()*bounds.getWidth() <= 1.0) {534 if (inter.isEmpty()  bounds.getHeight()*bounds.getWidth() <= eps) { 499 535 return PolygonIntersection.OUTSIDE; 500 536 } else if (inter.equals(a1)) {
Note: See TracChangeset
for help on using the changeset viewer.