Ignore:
Timestamp:
2014-05-30T10:27:18+02:00 (9 years ago)
Author:
bastiK
Message:

added right- and left-hand traffic database
(new mapcss pseudo-class-condition :righthandtraffic)

Data file (data/left-right-hand-traffic.osm) license: CC0.
Loosely based on boundary lines data from naturalearthdata.com.
Traffic law info from wikipedia.
Boundaries generalized, especially in areas where there seem to be no roads.
Should be mostly correct, but some remote islands and atolls may be assigned wrongly.
Alway check before you start driving. :)

Added fast lookup index similar to QuadBuckets.

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  
    444444    /**
    445445     * 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)
    447447     * @return Area for the given list of nodes
    448448     * @since 6841
     
    469469        return new Area(path);
    470470    }
     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    }
    471496
    472497    /**
     
    490515     */
    491516    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) {
    492528
    493529        Area inter = new Area(a1);
     
    496532        Rectangle bounds = inter.getBounds();
    497533
    498         if (inter.isEmpty() || bounds.getHeight()*bounds.getWidth() <= 1.0) {
     534        if (inter.isEmpty() || bounds.getHeight()*bounds.getWidth() <= eps) {
    499535            return PolygonIntersection.OUTSIDE;
    500536        } else if (inter.equals(a1)) {
Note: See TracChangeset for help on using the changeset viewer.