Search in sources :

Example 11 with OSMNode

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);
    }
}
Also used : OSMNode(org.opentripplanner.openstreetmap.model.OSMNode) Point(com.vividsolutions.jts.geom.Point) VLPoint(org.opentripplanner.visibility.VLPoint)

Example 12 with OSMNode

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");
}
Also used : CustomNamer(org.opentripplanner.graph_builder.services.osm.CustomNamer) Arrays(java.util.Arrays) OSMWithTags(org.opentripplanner.openstreetmap.model.OSMWithTags) LoggerFactory(org.slf4j.LoggerFactory) OsmVertex(org.opentripplanner.routing.vertextype.OsmVertex) StreetEdgeFactory(org.opentripplanner.graph_builder.services.StreetEdgeFactory) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) SphericalDistanceLibrary(org.opentripplanner.common.geometry.SphericalDistanceLibrary) LineString(com.vividsolutions.jts.geom.LineString) OSMNode(org.opentripplanner.openstreetmap.model.OSMNode) NonLocalizedString(org.opentripplanner.util.NonLocalizedString) ArrayList(java.util.ArrayList) Graph(org.opentripplanner.routing.graph.Graph) Coordinate(com.vividsolutions.jts.geom.Coordinate) Logger(org.slf4j.Logger) Vertex(org.opentripplanner.routing.graph.Vertex) I18NString(org.opentripplanner.util.I18NString) Math.min(java.lang.Math.min) Collectors(java.util.stream.Collectors) GeometryUtils(org.opentripplanner.common.geometry.GeometryUtils) List(java.util.List) AreaEdge(org.opentripplanner.routing.edgetype.AreaEdge) Math.max(java.lang.Math.max) GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) StreetTraversalPermission(org.opentripplanner.routing.edgetype.StreetTraversalPermission) Edge(org.opentripplanner.routing.graph.Edge) OsmVertex(org.opentripplanner.routing.vertextype.OsmVertex) Vertex(org.opentripplanner.routing.graph.Vertex) ArrayList(java.util.ArrayList) OSMNode(org.opentripplanner.openstreetmap.model.OSMNode) OsmVertex(org.opentripplanner.routing.vertextype.OsmVertex)

Example 13 with OSMNode

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"));
}
Also used : OSMWay(org.opentripplanner.openstreetmap.model.OSMWay) OSMNode(org.opentripplanner.openstreetmap.model.OSMNode)

Aggregations

OSMNode (org.opentripplanner.openstreetmap.model.OSMNode)13 VLPoint (org.opentripplanner.visibility.VLPoint)6 Point (com.vividsolutions.jts.geom.Point)5 ArrayList (java.util.ArrayList)5 LineString (com.vividsolutions.jts.geom.LineString)4 Coordinate (com.vividsolutions.jts.geom.Coordinate)3 P2 (org.opentripplanner.common.model.P2)3 AreaEdge (org.opentripplanner.routing.edgetype.AreaEdge)3 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)3 Edge (org.opentripplanner.routing.graph.Edge)3 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)2 LinearRing (com.vividsolutions.jts.geom.LinearRing)2 HashSet (java.util.HashSet)2 RingConstructionException (org.opentripplanner.graph_builder.module.osm.Ring.RingConstructionException)2 OSMWay (org.opentripplanner.openstreetmap.model.OSMWay)2 OSMWithTags (org.opentripplanner.openstreetmap.model.OSMWithTags)2 AreaEdgeList (org.opentripplanner.routing.edgetype.AreaEdgeList)2 NamedArea (org.opentripplanner.routing.edgetype.NamedArea)2 Graph (org.opentripplanner.routing.graph.Graph)2 Vertex (org.opentripplanner.routing.graph.Vertex)2