Changeset 7193 in josm
- Timestamp:
- 2014-05-30T10:27:18+02:00 (10 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/BBox.java
r6890 r7193 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import java.awt.geom.Rectangle2D; 4 5 import java.util.Arrays; 5 6 … … 259 260 return idx1; 260 261 } 262 263 public Rectangle2D toRectangle() { 264 return new Rectangle2D.Double(xmin, ymin, xmax - xmin, ymax - ymin); 265 } 261 266 262 267 @Override -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Condition.java
r7167 r7193 403 403 case "unconnected": 404 404 return e.osm instanceof Node && OsmPrimitive.getFilteredList(e.osm.getReferrers(), Way.class).isEmpty(); 405 case "righthandtraffic": 406 return ExpressionFactory.Functions.is_right_hand_traffic(e); 405 407 } 406 408 return false; -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java
r7170 r7193 26 26 import org.openstreetmap.josm.actions.search.SearchCompiler.Match; 27 27 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError; 28 import org.openstreetmap.josm.data.osm.Node; 28 29 import org.openstreetmap.josm.data.osm.OsmPrimitive; 29 30 import org.openstreetmap.josm.gui.mappaint.Cascade; … … 32 33 import org.openstreetmap.josm.tools.ColorHelper; 33 34 import org.openstreetmap.josm.tools.Predicates; 35 import org.openstreetmap.josm.tools.RightAndLefthandTraffic; 34 36 import org.openstreetmap.josm.tools.Utils; 35 37 … … 621 623 return cs.getValue(); 622 624 } 625 626 public static boolean is_right_hand_traffic(Environment env) { 627 if (env.osm instanceof Node) 628 return RightAndLefthandTraffic.isRightHandTraffic(((Node) env.osm).getCoor()); 629 return RightAndLefthandTraffic.isRightHandTraffic(env.osm.getBBox().getCenter()); 630 } 623 631 } 624 632 -
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.