Search in sources :

Example 1 with VLPoint

use of org.opentripplanner.visibility.VLPoint in project OpenTripPlanner by opentripplanner.

the class Ring method toCoordinates.

private Coordinate[] toCoordinates(VLPolygon geometry) {
    Coordinate[] coords = new Coordinate[geometry.n() + 1];
    int i = 0;
    for (VLPoint point : geometry.vertices) {
        coords[i++] = new Coordinate(point.x, point.y);
    }
    VLPoint first = geometry.vertices.get(0);
    coords[i++] = new Coordinate(first.x, first.y);
    return coords;
}
Also used : Coordinate(com.vividsolutions.jts.geom.Coordinate) VLPoint(org.opentripplanner.visibility.VLPoint) VLPoint(org.opentripplanner.visibility.VLPoint)

Example 2 with VLPoint

use of org.opentripplanner.visibility.VLPoint in project OpenTripPlanner by opentripplanner.

the class TestVisibilityGraph method poly.

public static VLPolygon poly(double... coords) {
    ArrayList<VLPoint> points = new ArrayList<VLPoint>();
    for (int i = 0; i < coords.length; i += 2) {
        VLPoint point = new VLPoint(coords[i], coords[i + 1]);
        points.add(point);
    }
    return new VLPolygon(points);
}
Also used : ArrayList(java.util.ArrayList) VLPoint(org.opentripplanner.visibility.VLPoint) VLPolygon(org.opentripplanner.visibility.VLPolygon) VLPoint(org.opentripplanner.visibility.VLPoint)

Example 3 with VLPoint

use of org.opentripplanner.visibility.VLPoint in project OpenTripPlanner by opentripplanner.

the class WalkableAreaBuilder method toJTSPolygon.

private Polygon toJTSPolygon(VLPolygon visibilityPolygon) {
    if (visibilityPolygon.vertices.isEmpty()) {
        return null;
    }
    // incomprehensibly, visilibity's routines for figuring out point-polygon containment are
    // too broken
    // to use here, so we have to fall back to JTS.
    Coordinate[] coordinates = new Coordinate[visibilityPolygon.n() + 1];
    for (int p = 0; p < coordinates.length; ++p) {
        VLPoint vlPoint = visibilityPolygon.get(p);
        coordinates[p] = new Coordinate(vlPoint.x, vlPoint.y);
    }
    LinearRing shell = GeometryUtils.getGeometryFactory().createLinearRing(coordinates);
    Polygon poly = GeometryUtils.getGeometryFactory().createPolygon(shell, new LinearRing[0]);
    return poly;
}
Also used : Coordinate(com.vividsolutions.jts.geom.Coordinate) VLPoint(org.opentripplanner.visibility.VLPoint) LinearRing(com.vividsolutions.jts.geom.LinearRing) VLPolygon(org.opentripplanner.visibility.VLPolygon) MultiPolygon(com.vividsolutions.jts.geom.MultiPolygon) VisibilityPolygon(org.opentripplanner.visibility.VisibilityPolygon) Polygon(com.vividsolutions.jts.geom.Polygon) Point(com.vividsolutions.jts.geom.Point) VLPoint(org.opentripplanner.visibility.VLPoint)

Example 4 with VLPoint

use of org.opentripplanner.visibility.VLPoint in project OpenTripPlanner by opentripplanner.

the class WalkableAreaBuilder method addtoVisibilityAndStartSets.

private void addtoVisibilityAndStartSets(Set<OSMNode> startingNodes, ArrayList<VLPoint> visibilityPoints, ArrayList<OSMNode> visibilityNodes, OSMNode node) {
    if (osmdb.isNodeBelongsToWay(node.getId()) || osmdb.isNodeSharedByMultipleAreas(node.getId()) || node.isStop()) {
        startingNodes.add(node);
        VLPoint point = new VLPoint(node.lon, node.lat);
        if (!visibilityPoints.contains(point)) {
            visibilityPoints.add(point);
            visibilityNodes.add(node);
        }
    }
}
Also used : VLPoint(org.opentripplanner.visibility.VLPoint)

Example 5 with VLPoint

use of org.opentripplanner.visibility.VLPoint in project OpenTripPlanner by opentripplanner.

the class WalkableAreaBuilder method accumulateRingNodes.

private void accumulateRingNodes(Ring ring, List<OSMNode> nodes, List<VLPoint> vertices) {
    for (OSMNode node : ring.nodes) {
        if (nodes.contains(node)) {
            // close polygons
            continue;
        }
        VLPoint point = new VLPoint(node.lon, node.lat);
        nodes.add(node);
        vertices.add(point);
    }
}
Also used : VLPoint(org.opentripplanner.visibility.VLPoint) OSMNode(org.opentripplanner.openstreetmap.model.OSMNode)

Aggregations

VLPoint (org.opentripplanner.visibility.VLPoint)8 Point (com.vividsolutions.jts.geom.Point)4 OSMNode (org.opentripplanner.openstreetmap.model.OSMNode)4 Coordinate (com.vividsolutions.jts.geom.Coordinate)3 ArrayList (java.util.ArrayList)3 VLPolygon (org.opentripplanner.visibility.VLPolygon)3 LinearRing (com.vividsolutions.jts.geom.LinearRing)2 MultiPolygon (com.vividsolutions.jts.geom.MultiPolygon)2 Polygon (com.vividsolutions.jts.geom.Polygon)2 VisibilityPolygon (org.opentripplanner.visibility.VisibilityPolygon)2 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)1 LineString (com.vividsolutions.jts.geom.LineString)1 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)1 HashSet (java.util.HashSet)1 P2 (org.opentripplanner.common.model.P2)1 OSMWithTags (org.opentripplanner.openstreetmap.model.OSMWithTags)1 AreaEdge (org.opentripplanner.routing.edgetype.AreaEdge)1 AreaEdgeList (org.opentripplanner.routing.edgetype.AreaEdgeList)1 NamedArea (org.opentripplanner.routing.edgetype.NamedArea)1 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)1