Search in sources :

Example 1 with AnyFileBasedOpenStreetMapProviderImpl

use of org.opentripplanner.openstreetmap.impl.AnyFileBasedOpenStreetMapProviderImpl in project OpenTripPlanner by opentripplanner.

the class FakeGraph method buildGraphNoTransit.

/**
 * Build a graph in Columbus, OH with no transit
 */
public static Graph buildGraphNoTransit() throws UnsupportedEncodingException {
    Graph gg = new Graph();
    OpenStreetMapModule loader = new OpenStreetMapModule();
    loader.setDefaultWayPropertySetSource(new DefaultWayPropertySetSource());
    AnyFileBasedOpenStreetMapProviderImpl provider = new AnyFileBasedOpenStreetMapProviderImpl();
    File file = new File(URLDecoder.decode(FakeGraph.class.getResource("columbus.osm.pbf").getFile(), "UTF-8"));
    provider.setPath(file);
    loader.setProvider(provider);
    loader.buildGraph(gg, new HashMap<Class<?>, Object>());
    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) AnyFileBasedOpenStreetMapProviderImpl(org.opentripplanner.openstreetmap.impl.AnyFileBasedOpenStreetMapProviderImpl) File(java.io.File)

Example 2 with AnyFileBasedOpenStreetMapProviderImpl

use of org.opentripplanner.openstreetmap.impl.AnyFileBasedOpenStreetMapProviderImpl in project OpenTripPlanner by opentripplanner.

the class OpenStreetMapParserTest method testAFXMLParser.

@Test
public void testAFXMLParser() throws Exception {
    AnyFileBasedOpenStreetMapProviderImpl pr = new AnyFileBasedOpenStreetMapProviderImpl();
    OSMMap map = new OSMMap();
    pr.setPath(new File(URLDecoder.decode(getClass().getResource("map.osm.gz").getPath(), "UTF-8")));
    pr.readOSM(map);
    testParser(map);
}
Also used : AnyFileBasedOpenStreetMapProviderImpl(org.opentripplanner.openstreetmap.impl.AnyFileBasedOpenStreetMapProviderImpl) OSMMap(org.opentripplanner.openstreetmap.model.OSMMap) File(java.io.File) Test(org.junit.Test)

Example 3 with AnyFileBasedOpenStreetMapProviderImpl

use of org.opentripplanner.openstreetmap.impl.AnyFileBasedOpenStreetMapProviderImpl in project OpenTripPlanner by opentripplanner.

the class TestUnroutable method setUp.

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

Example 4 with AnyFileBasedOpenStreetMapProviderImpl

use of org.opentripplanner.openstreetmap.impl.AnyFileBasedOpenStreetMapProviderImpl 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());
    AnyFileBasedOpenStreetMapProviderImpl provider = new AnyFileBasedOpenStreetMapProviderImpl();
    File file = new File(URLDecoder.decode(FakeGraph.class.getResource("osm/skoyen.osm.pbf").getFile(), "UTF-8"));
    provider.setPath(file);
    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) 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) AnyFileBasedOpenStreetMapProviderImpl(org.opentripplanner.openstreetmap.impl.AnyFileBasedOpenStreetMapProviderImpl) 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) AnyFileBasedOpenStreetMapProviderImpl(org.opentripplanner.openstreetmap.impl.AnyFileBasedOpenStreetMapProviderImpl) File(java.io.File) Test(org.junit.Test)

Example 5 with AnyFileBasedOpenStreetMapProviderImpl

use of org.opentripplanner.openstreetmap.impl.AnyFileBasedOpenStreetMapProviderImpl in project OpenTripPlanner by opentripplanner.

the class OpenStreetMapParserTest method testAFBinaryParser.

@Test
public void testAFBinaryParser() throws Exception {
    AnyFileBasedOpenStreetMapProviderImpl pr = new AnyFileBasedOpenStreetMapProviderImpl();
    OSMMap map = new OSMMap();
    pr.setPath(new File(URLDecoder.decode(getClass().getResource("map.osm.pbf").getPath(), "UTF-8")));
    pr.readOSM(map);
    testParser(map);
}
Also used : AnyFileBasedOpenStreetMapProviderImpl(org.opentripplanner.openstreetmap.impl.AnyFileBasedOpenStreetMapProviderImpl) OSMMap(org.opentripplanner.openstreetmap.model.OSMMap) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)6 AnyFileBasedOpenStreetMapProviderImpl (org.opentripplanner.openstreetmap.impl.AnyFileBasedOpenStreetMapProviderImpl)6 Test (org.junit.Test)3 OpenStreetMapModule (org.opentripplanner.graph_builder.module.osm.OpenStreetMapModule)2 OSMMap (org.opentripplanner.openstreetmap.model.OSMMap)2 Graph (org.opentripplanner.routing.graph.Graph)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 URL (java.net.URL)1 URLDecoder (java.net.URLDecoder)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 ZipFile (java.util.zip.ZipFile)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 GtfsBundle (org.opentripplanner.graph_builder.model.GtfsBundle)1 DirectTransferGenerator (org.opentripplanner.graph_builder.module.DirectTransferGenerator)1 EmbedConfig (org.opentripplanner.graph_builder.module.EmbedConfig)1 FakeGraph (org.opentripplanner.graph_builder.module.FakeGraph)1 GtfsModule (org.opentripplanner.graph_builder.module.GtfsModule)1