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;
}
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);
}
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;
}
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);
}
}
}
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);
}
}
Aggregations