Search in sources :

Example 1 with BinaryOpenStreetMapProvider

use of org.opentripplanner.openstreetmap.BinaryOpenStreetMapProvider in project OpenTripPlanner by opentripplanner.

the class ConstantsForTests method setupPortland.

private void setupPortland() {
    try {
        portlandGraph = new Graph();
        // Add street data from OSM
        {
            File osmFile = new File(PORTLAND_CENTRAL_OSM);
            BinaryOpenStreetMapProvider osmProvider = new BinaryOpenStreetMapProvider(osmFile, false);
            OpenStreetMapModule osmModule = new OpenStreetMapModule(Lists.newArrayList(osmProvider));
            osmModule.skipVisibility = true;
            osmModule.buildGraph(portlandGraph, new HashMap<>());
        }
        // Add transit data from GTFS
        {
            portlandContext = contextBuilder(ConstantsForTests.PORTLAND_GTFS).withIssueStoreAndDeduplicator(portlandGraph).build();
            AddTransitModelEntitiesToGraph.addToGraph(portlandContext, portlandGraph);
            GeometryAndBlockProcessor factory = new GeometryAndBlockProcessor(portlandContext);
            factory.run(portlandGraph);
        }
        // Link transit stops to streets
        {
            GraphBuilderModule streetTransitLinker = new StreetLinkerModule();
            streetTransitLinker.buildGraph(portlandGraph, new HashMap<>());
        }
        // TODO: eliminate GTFSContext
        // this is now making a duplicate calendarservicedata but it's oh so practical
        portlandGraph.putService(CalendarServiceData.class, portlandContext.getCalendarServiceData());
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
}
Also used : GeometryAndBlockProcessor(org.opentripplanner.graph_builder.module.geometry.GeometryAndBlockProcessor) Graph(org.opentripplanner.routing.graph.Graph) AddTransitModelEntitiesToGraph(org.opentripplanner.graph_builder.module.AddTransitModelEntitiesToGraph) OpenStreetMapModule(org.opentripplanner.graph_builder.module.osm.OpenStreetMapModule) HashMap(java.util.HashMap) BinaryOpenStreetMapProvider(org.opentripplanner.openstreetmap.BinaryOpenStreetMapProvider) GraphBuilderModule(org.opentripplanner.graph_builder.services.GraphBuilderModule) File(java.io.File) StreetLinkerModule(org.opentripplanner.graph_builder.module.StreetLinkerModule) IOException(java.io.IOException)

Example 2 with BinaryOpenStreetMapProvider

use of org.opentripplanner.openstreetmap.BinaryOpenStreetMapProvider in project OpenTripPlanner by opentripplanner.

the class TestUnroutable method setUp.

public void setUp() throws Exception {
    OpenStreetMapModule osmBuilder = new OpenStreetMapModule();
    osmBuilder.setDefaultWayPropertySetSource(new DefaultWayPropertySetSource());
    URL osmDataUrl = getClass().getResource("bridge_construction.osm.pbf");
    File osmDataFile = new File(URLDecoder.decode(osmDataUrl.getFile(), "UTF-8"));
    BinaryOpenStreetMapProvider provider = new BinaryOpenStreetMapProvider(osmDataFile, true);
    osmBuilder.setProvider(provider);
    HashMap<Class<?>, Object> extra = Maps.newHashMap();
    // TODO get rid of this "extra" thing
    osmBuilder.buildGraph(graph, extra);
}
Also used : BinaryOpenStreetMapProvider(org.opentripplanner.openstreetmap.BinaryOpenStreetMapProvider) File(java.io.File) URL(java.net.URL)

Example 3 with BinaryOpenStreetMapProvider

use of org.opentripplanner.openstreetmap.BinaryOpenStreetMapProvider in project OpenTripPlanner by opentripplanner.

the class FakeGraph method buildGraphNoTransit.

/**
 * Build a graph in Columbus, OH with no transit
 */
public static Graph buildGraphNoTransit() {
    Graph gg = new Graph();
    OpenStreetMapModule loader = new OpenStreetMapModule();
    loader.setDefaultWayPropertySetSource(new DefaultWayPropertySetSource());
    File file = getFileForResource("columbus.osm.pbf");
    BinaryOpenStreetMapProvider provider = new BinaryOpenStreetMapProvider(file, false);
    loader.setProvider(provider);
    loader.buildGraph(gg, new HashMap<>());
    return gg;
}
Also used : Graph(org.opentripplanner.routing.graph.Graph) OpenStreetMapModule(org.opentripplanner.graph_builder.module.osm.OpenStreetMapModule) DefaultWayPropertySetSource(org.opentripplanner.graph_builder.module.osm.DefaultWayPropertySetSource) BinaryOpenStreetMapProvider(org.opentripplanner.openstreetmap.BinaryOpenStreetMapProvider) File(java.io.File)

Example 4 with BinaryOpenStreetMapProvider

use of org.opentripplanner.openstreetmap.BinaryOpenStreetMapProvider in project OpenTripPlanner by opentripplanner.

the class PlatformLinkerTest method testLinkEntriesToPlatforms.

/**
 * Test linking from stairs endpoint to to nodes in the ring defining the platform area.
 * OSM test data is from Skøyen station, Norway
 */
@Test
public void testLinkEntriesToPlatforms() throws Exception {
    String stairsEndpointLabel = "osm:node:1028861028";
    List<String> platformRingVertexLabels = Arrays.asList("osm:node:304045332", "osm:node:3238357455", "osm:node:1475363433", "osm:node:3238357491", "osm:node:1475363427", "osm:node:304045336", "osm:node:304045337", "osm:node:1475363437", "osm:node:3238357483", "osm:node:1475363443", "osm:node:1028860941", "osm:node:304045341", "osm:node:304045332");
    Graph gg = new Graph();
    OpenStreetMapModule loader = new OpenStreetMapModule();
    loader.platformEntriesLinking = true;
    loader.skipVisibility = true;
    loader.setDefaultWayPropertySetSource(new DefaultWayPropertySetSource());
    File file = new File(URLDecoder.decode(FakeGraph.class.getResource("osm/skoyen.osm.pbf").getFile(), "UTF-8"));
    BinaryOpenStreetMapProvider provider = new BinaryOpenStreetMapProvider(file, false);
    loader.setProvider(provider);
    loader.buildGraph(gg, new HashMap<>());
    Vertex stairsEndpoint = gg.getVertex(stairsEndpointLabel);
    // verify outgoing links
    List<String> linkedRingVertecies = stairsEndpoint.getOutgoing().stream().map(edge -> edge.getToVertex().getLabel()).collect(Collectors.toList());
    // the endpoint has links to two nodes in OSM
    assertEquals(linkedRingVertecies.size() - 2, platformRingVertexLabels.size());
    for (String label : platformRingVertexLabels) {
        assert (linkedRingVertecies.contains(label));
    }
    // verify incoming links
    List<String> linkedRingVerteciesInn = stairsEndpoint.getIncoming().stream().map(edge -> edge.getFromVertex().getLabel()).collect(Collectors.toList());
    // the endpoint has links to two nodes in OSM
    assertEquals(linkedRingVerteciesInn.size() - 2, platformRingVertexLabels.size());
    for (String label : platformRingVertexLabels) {
        assert (linkedRingVerteciesInn.contains(label));
    }
}
Also used : Arrays(java.util.Arrays) List(java.util.List) URLDecoder(java.net.URLDecoder) Graph(org.opentripplanner.routing.graph.Graph) Vertex(org.opentripplanner.routing.graph.Vertex) BinaryOpenStreetMapProvider(org.opentripplanner.openstreetmap.BinaryOpenStreetMapProvider) Test(org.junit.Test) FakeGraph(org.opentripplanner.graph_builder.module.FakeGraph) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) File(java.io.File) Assert.assertEquals(org.junit.Assert.assertEquals) Vertex(org.opentripplanner.routing.graph.Vertex) Graph(org.opentripplanner.routing.graph.Graph) FakeGraph(org.opentripplanner.graph_builder.module.FakeGraph) FakeGraph(org.opentripplanner.graph_builder.module.FakeGraph) BinaryOpenStreetMapProvider(org.opentripplanner.openstreetmap.BinaryOpenStreetMapProvider) File(java.io.File) Test(org.junit.Test)

Example 5 with BinaryOpenStreetMapProvider

use of org.opentripplanner.openstreetmap.BinaryOpenStreetMapProvider in project OpenTripPlanner by opentripplanner.

the class TestOpenStreetMapGraphBuilder method testGraphBuilder.

@Test
public void testGraphBuilder() throws Exception {
    Graph gg = new Graph();
    OpenStreetMapModule loader = new OpenStreetMapModule();
    loader.setDefaultWayPropertySetSource(new DefaultWayPropertySetSource());
    File file = new File(URLDecoder.decode(getClass().getResource("map.osm.pbf").getFile(), "UTF-8"));
    BinaryOpenStreetMapProvider provider = new BinaryOpenStreetMapProvider(file, true);
    loader.setProvider(provider);
    loader.buildGraph(gg, extra);
    // Kamiennogorska at south end of segment
    Vertex v1 = gg.getVertex("osm:node:280592578");
    // Kamiennogorska at Mariana Smoluchowskiego
    Vertex v2 = gg.getVertex("osm:node:288969929");
    // Mariana Smoluchowskiego, north end
    Vertex v3 = gg.getVertex("osm:node:280107802");
    // Mariana Smoluchowskiego, south end (of segment connected to v2)
    Vertex v4 = gg.getVertex("osm:node:288970952");
    assertNotNull(v1);
    assertNotNull(v2);
    assertNotNull(v3);
    assertNotNull(v4);
    Edge e1 = null, e2 = null, e3 = null;
    for (Edge e : v2.getOutgoing()) {
        if (e.getToVertex() == v1) {
            e1 = e;
        } else if (e.getToVertex() == v3) {
            e2 = e;
        } else if (e.getToVertex() == v4) {
            e3 = e;
        }
    }
    assertNotNull(e1);
    assertNotNull(e2);
    assertNotNull(e3);
    assertTrue("name of e1 must be like \"Kamiennog\u00F3rska\"; was " + e1.getName(), e1.getName().contains("Kamiennog\u00F3rska"));
    assertTrue("name of e2 must be like \"Mariana Smoluchowskiego\"; was " + e2.getName(), e2.getName().contains("Mariana Smoluchowskiego"));
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) Graph(org.opentripplanner.routing.graph.Graph) BinaryOpenStreetMapProvider(org.opentripplanner.openstreetmap.BinaryOpenStreetMapProvider) File(java.io.File) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) Edge(org.opentripplanner.routing.graph.Edge) Test(org.junit.Test)

Aggregations

BinaryOpenStreetMapProvider (org.opentripplanner.openstreetmap.BinaryOpenStreetMapProvider)14 File (java.io.File)13 Graph (org.opentripplanner.routing.graph.Graph)10 Vertex (org.opentripplanner.routing.graph.Vertex)7 Test (org.junit.Test)6 Edge (org.opentripplanner.routing.graph.Edge)4 ArrayList (java.util.ArrayList)3 OpenStreetMapModule (org.opentripplanner.graph_builder.module.osm.OpenStreetMapModule)3 ParkAndRideEdge (org.opentripplanner.routing.edgetype.ParkAndRideEdge)3 ParkAndRideLinkEdge (org.opentripplanner.routing.edgetype.ParkAndRideLinkEdge)3 IntersectionVertex (org.opentripplanner.routing.vertextype.IntersectionVertex)3 ParkAndRideVertex (org.opentripplanner.routing.vertextype.ParkAndRideVertex)3 HashMap (java.util.HashMap)2 DataSource (org.opentripplanner.datastore.DataSource)2 DataImportIssueStore (org.opentripplanner.graph_builder.DataImportIssueStore)2 StreetLinkerModule (org.opentripplanner.graph_builder.module.StreetLinkerModule)2 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)2 TLongList (gnu.trove.list.TLongList)1 IOException (java.io.IOException)1 URL (java.net.URL)1