Search in sources :

Example 6 with Environment

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

the class TestVisibilityGraph method testPalazzo.

// Another Venice test case
public void testPalazzo() {
    VLPolygon poly = poly(12.3402039, 45.4342526, 12.339956, 45.43421, 12.3401159, 45.4338161, 12.3404923, 45.4338996, 12.3402845, 45.4344296, 12.3402433, 45.4344174, 12.3401433, 45.4343973, 12.3401691, 45.4343433);
    Environment environment = new Environment(Arrays.asList(poly));
    environment.enforce_standard_form();
    VisibilityGraph vg = new VisibilityGraph(environment, 0.0000001);
    boolean[][] expected = { { true, true, true, false, false, false, false, true }, { true, true, true, true, true, false, false, true }, { true, true, true, true, true, true, true, true }, { false, true, true, true, true, false, true, true }, { false, true, true, true, true, true, true, true }, { false, false, true, false, true, true, true, false }, { false, false, true, true, true, true, true, true }, { true, true, true, true, true, false, true, true } };
    for (int i = 0; i < expected.length; ++i) {
        for (int j = 0; j < expected[i].length; ++j) {
            assertEquals(" at " + i + ", " + j, expected[i][j], vg.get(i, j));
        }
    }
}
Also used : VLPolygon(org.opentripplanner.visibility.VLPolygon) Environment(org.opentripplanner.visibility.Environment) VisibilityGraph(org.opentripplanner.visibility.VisibilityGraph) VLPoint(org.opentripplanner.visibility.VLPoint)

Example 7 with Environment

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

the class TestVisibilityGraph method testSquareCenteredInSquare.

public void testSquareCenteredInSquare() {
    Environment environment = new Environment(Arrays.asList(poly(1, 1, 5, 1, 5, 5, 1, 5), poly(2, 3.5, 2, 4.5, 3, 4.5, 3, 3.5)));
    environment.enforce_standard_form();
    VisibilityGraph vg = new VisibilityGraph(environment, 0.01);
    boolean[][] expected = { { true, true, true, true, true, true, false, true }, { true, true, true, false, true, false, true, true }, { true, true, true, true, false, true, true, true }, { true, false, true, true, true, true, true, false }, { true, true, false, true, true, true, false, true }, { true, false, true, true, true, true, true, false }, { false, true, true, true, false, true, true, true }, { true, true, true, false, true, false, true, true } };
    for (int i = 0; i < expected.length; ++i) {
        for (int j = 0; j < expected[i].length; ++j) {
            assertEquals("difference at " + i + ", " + j, expected[i][j], vg.get(i, j));
        }
    }
}
Also used : Environment(org.opentripplanner.visibility.Environment) VisibilityGraph(org.opentripplanner.visibility.VisibilityGraph) VLPoint(org.opentripplanner.visibility.VLPoint)

Aggregations

Environment (org.opentripplanner.visibility.Environment)7 VLPoint (org.opentripplanner.visibility.VLPoint)7 VisibilityGraph (org.opentripplanner.visibility.VisibilityGraph)6 VLPolygon (org.opentripplanner.visibility.VLPolygon)5 Coordinate (com.vividsolutions.jts.geom.Coordinate)1 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)1 LineString (com.vividsolutions.jts.geom.LineString)1 LinearRing (com.vividsolutions.jts.geom.LinearRing)1 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)1 MultiPolygon (com.vividsolutions.jts.geom.MultiPolygon)1 Point (com.vividsolutions.jts.geom.Point)1 Polygon (com.vividsolutions.jts.geom.Polygon)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 P2 (org.opentripplanner.common.model.P2)1 OSMNode (org.opentripplanner.openstreetmap.model.OSMNode)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