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