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