use of org.opentripplanner.openstreetmap.model.OSMNode in project OpenTripPlanner by opentripplanner.
the class WalkableAreaBuilder method reversePolygonOfOSMNodes.
private void reversePolygonOfOSMNodes(List<OSMNode> nodes) {
for (int i = 1; i < (nodes.size() + 1) / 2; ++i) {
OSMNode tmp = nodes.get(i);
int opposite = nodes.size() - i;
nodes.set(i, nodes.get(opposite));
nodes.set(opposite, tmp);
}
}
use of org.opentripplanner.openstreetmap.model.OSMNode in project OpenTripPlanner by opentripplanner.
the class PlatformLinker method linkEntriesToPlatforms.
void linkEntriesToPlatforms() {
LOG.info("Start linking platforms");
List<OsmVertex> endpoints = graph.getVertices().stream().filter(OsmVertex.class::isInstance).map(OsmVertex.class::cast).filter(this::isEndpoint).collect(Collectors.toList());
LOG.info("Endpoints found: " + endpoints.size());
List<Area> platforms = osmdb.getWalkableAreas().stream().filter(area -> "platform".equals(area.parent.getTag("public_transport")) && "platform".equals(area.parent.getTag("railway"))).collect(Collectors.toList());
LOG.info("Platforms found: " + platforms.size());
for (Area area : platforms) {
List<OsmVertex> endpointsWithin = new ArrayList<>();
List<Ring> rings = area.outermostRings;
for (Ring ring : rings) {
endpointsWithin.addAll(endpoints.stream().filter(t -> contains(ring, t)).collect(Collectors.toList()));
for (OSMNode node : ring.nodes) {
Vertex vertexById = graph.getVertex("osm:node:" + node.getId());
if (vertexById != null) {
endpointsWithin.forEach(e -> makePlatformEdges(area, e, (OsmVertex) vertexById));
}
}
}
}
LOG.info("Done linking platforms");
}
use of org.opentripplanner.openstreetmap.model.OSMNode in project OpenTripPlanner by opentripplanner.
the class OpenStreetMapParserTest method testParser.
public void testParser(OSMMap map) throws Exception {
Map<Long, OSMNode> nodes = map.getNodes();
assertEquals(7197, nodes.size());
OSMNode nodeA = map.getNodeForId(27308461);
assertEquals(27308461, nodeA.getId());
assertEquals(52.3887673, nodeA.lat, 0.0000001);
assertEquals(16.8506243, nodeA.lon, 0.0000001);
Map<String, String> tags = nodeA.getTags();
assertEquals("JOSM", tags.get("created_by"));
assertEquals("survey", tags.get("source"));
OSMNode nodeB = map.getNodeForId(27308457);
assertEquals(27308457, nodeB.getId());
assertEquals(52.3850672, nodeB.lat, 0.0000001);
assertEquals(16.8396962, nodeB.lon, 0.0000001);
tags = nodeB.getTags();
assertEquals("Wieruszowska", tags.get("name"));
assertEquals("tram_stop", tags.get("railway"));
assertEquals("survey", tags.get("source"));
assertEquals("1", tags.get("layer"));
OSMNode nodeC = map.getNodeForId(299769943);
assertTrue(nodeC.hasTag("name"));
assertNull(nodeC.getTag("not-existing-tag"));
assertEquals("Apteka Junikowska", nodeC.getTag("name"));
assertTrue(nodeC.isTagTrue("dispensing"));
assertFalse(nodeC.isTagFalse("dispensing"));
assertFalse(nodeC.isTagTrue("not-existing-tag"));
assertFalse(nodeC.isTagFalse("not-existing-tag"));
OSMNode nodeD = map.getNodeForId(338912397);
assertTrue(nodeD.isTagFalse("dispensing"));
assertFalse(nodeD.isTagTrue("dispensing"));
Map<Long, OSMWay> ways = map.getWays();
assertEquals(1511, ways.size());
OSMWay wayA = map.getWayForId(13490353);
assertEquals(13490353, wayA.getId());
List<Long> nodeRefsA = wayA.getNodeRefs();
assertEquals(2, nodeRefsA.size());
assertEquals(123978834, nodeRefsA.get(0).longValue());
assertEquals(123980465, nodeRefsA.get(1).longValue());
tags = wayA.getTags();
assertEquals("Potlatch 0.9a", tags.get("created_by"));
assertEquals("secondary", tags.get("highway"));
}
Aggregations