Search in sources :

Example 1 with VLPolygon

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

the class TestVisibilityGraph method testConcavePolygon.

public void testConcavePolygon() {
    VLPolygon poly = poly(1, 1, 5, 1, 5, 5, 3, 5, 3, 4, 4, 4, 4, 2, 2, 2, 2, 3, 1, 3);
    if (poly.area() < 0) {
        poly.reverse();
    }
    Environment environment = new Environment(Arrays.asList(poly));
    environment.enforce_standard_form();
    VisibilityGraph vg = new VisibilityGraph(environment, 0.01);
    boolean[][] expected = { { true, true, false, false, false, false, true, true, true, true }, { true, true, true, false, false, true, true, true, false, false }, { false, true, true, true, true, true, true, false, false, false }, { false, false, true, true, true, true, false, false, false, false }, { false, false, true, true, true, true, false, false, false, false }, { false, true, true, true, true, true, true, false, false, false }, { true, true, true, false, false, true, true, true, false, false }, { true, true, false, false, false, false, true, true, true, true }, { true, false, false, false, false, false, false, true, true, true }, { true, false, false, false, false, false, false, true, true, true } };
    for (int i = 0; i < expected.length; ++i) {
        for (int j = 0; j < expected[i].length; ++j) {
            assertEquals(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 2 with VLPolygon

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

the class TestVisibilityGraph method testPolygonReverse.

// test the polygon.reverse() function
public void testPolygonReverse() {
    VLPolygon poly = poly(12.3402039, 45.4342526, 12.3401691, 45.4343433, 12.3401433, 45.4343973, 12.3402433, 45.4344174, 12.3402845, 45.4344296, 12.3404923, 45.4338996, 12.3401159, 45.4338161, 12.339956, 45.43421);
    VLPolygon poly2 = 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);
    poly.reverse();
    assertTrue(poly.equals(poly2));
}
Also used : VLPolygon(org.opentripplanner.visibility.VLPolygon)

Example 3 with VLPolygon

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

the class TestVisibilityGraph method testConcavePolygon2.

// A massively reduced version of the Piazza San Marco, which
// caused problems when the code was buggy
public void testConcavePolygon2() {
    VLPolygon poly = poly(17.0, 14.0, 70.0, 18.0, 69.0, 26.0, 39.0, 20.0, 13.0, 78.0, -111.0, 24.0);
    Environment environment = new Environment(Arrays.asList(poly));
    environment.enforce_standard_form();
    VisibilityGraph vg = new VisibilityGraph(environment, 0.0000001);
    boolean[][] expected = { { true, true, true, false, true, true }, { true, true, true, true, true, true }, { true, true, true, true, true, false }, { false, true, true, true, true, false }, { true, true, true, true, true, true }, { true, true, false, 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 4 with VLPolygon

use of org.opentripplanner.visibility.VLPolygon 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 5 with VLPolygon

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

the class TestVisibilityGraph method testSanMarco.

// The Piazza San Marco in Venice, from OSM.
public void testSanMarco() {
    VLPolygon poly = poly(12.3389861, 45.4339415, 12.3389153, 45.4340763, 12.3390769, 45.4341172, 12.3391694, 45.4341388, 12.3392136, 45.4340533, 12.3397036, 45.434177, 12.339797, 45.4341939, 12.3397873, 45.4342286, 12.339706, 45.4342158, 12.3396866, 45.4342575, 12.3393905, 45.434195, 12.3391779, 45.4346848, 12.3391272, 45.4347845, 12.3390937, 45.4347676, 12.3389625, 45.4347071, 12.3386095, 45.4345509, 12.3379792, 45.4342771, 12.3378901, 45.4342367, 12.3376881, 45.4341478, 12.337471, 45.4340513, 12.3373322, 45.4339869, 12.3371759, 45.4339216, 12.3372951, 45.4336885, 12.3374061, 45.4334649, 12.3374185, 45.4334486, 12.3391652, 45.4339348, 12.3391453, 45.4339861);
    Environment environment = new Environment(Arrays.asList(poly));
    environment.enforce_standard_form();
    VisibilityGraph vg = new VisibilityGraph(environment, 0.0000001);
    boolean[][] expected = { { true, true, false, true, true, false, true, true, true, true, false, false, false, false, true, false, true, true, false, false, false, false, false, false, false, false, true }, { true, true, true, true, true, false, true, true, true, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, true, true, true }, { false, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, true, true }, { true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, true, true }, { true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true }, { false, false, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false }, { true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true }, { true, true, true, true, false, false, true, true, true, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, true, true }, { true, true, false, false, false, false, false, true, true, true, false, false, false, false, false, false, true, true, true, true, true, true, true, true, true, true, true }, { true, false, false, false, false, false, false, false, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true }, { false, false, false, false, false, false, false, false, false, true, true, true, false, true, true, true, true, true, true, true, true, false, false, false, false, false, false }, { false, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, false, false, false, false, false, false, true, true, true, false }, { false, false, false, false, false, false, false, false, false, true, false, true, true, true, true, false, true, false, false, false, false, false, false, false, true, true, true }, { false, false, false, false, false, false, false, false, false, false, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false }, { true, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, true, true }, { false, false, false, false, false, false, false, false, false, true, true, true, false, false, true, true, true, false, false, false, false, false, false, false, false, false, false }, { true, true, false, false, false, false, false, false, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true }, { true, true, true, true, false, false, false, true, true, true, true, false, false, false, false, false, true, true, true, true, true, true, true, true, true, true, true }, { false, true, true, true, false, false, false, true, true, true, true, false, false, false, false, false, true, true, true, true, false, false, false, false, false, false, false }, { false, true, true, true, false, false, false, true, true, true, true, false, false, false, false, false, true, true, true, true, true, false, false, false, false, false, false }, { false, true, true, true, false, false, false, true, true, true, true, false, false, false, false, false, true, true, false, true, true, true, false, false, false, false, false }, { false, true, true, true, false, false, true, true, true, true, false, false, false, false, false, false, true, true, false, false, true, true, true, true, true, true, true }, { false, true, true, true, false, false, true, true, true, true, false, false, false, false, false, false, true, true, false, false, false, true, true, true, false, false, false }, { false, true, true, true, false, false, true, true, true, true, false, true, false, false, false, false, true, true, false, false, false, true, true, true, true, true, true }, { false, true, true, true, false, false, true, true, true, true, false, true, true, false, false, false, true, true, false, false, false, true, false, true, true, true, true }, { false, true, true, true, false, false, true, true, true, true, false, true, true, false, true, false, true, true, false, false, false, true, false, true, true, true, true }, { true, true, true, true, true, false, true, true, true, true, false, false, true, false, true, false, true, true, false, false, false, true, false, true, true, 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)

Aggregations

VLPolygon (org.opentripplanner.visibility.VLPolygon)9 VLPoint (org.opentripplanner.visibility.VLPoint)7 Environment (org.opentripplanner.visibility.Environment)5 VisibilityGraph (org.opentripplanner.visibility.VisibilityGraph)4 Coordinate (com.vividsolutions.jts.geom.Coordinate)2 LinearRing (com.vividsolutions.jts.geom.LinearRing)2 MultiPolygon (com.vividsolutions.jts.geom.MultiPolygon)2 Point (com.vividsolutions.jts.geom.Point)2 Polygon (com.vividsolutions.jts.geom.Polygon)2 ArrayList (java.util.ArrayList)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 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