Examples of OSMWay


Examples of org.opentripplanner.openstreetmap.model.OSMWay

                osmNode.lon = Double.parseDouble(element.getAttribute("lon"));

                processTags(osmNode, element);
                map.addNode(osmNode);
            } else if (phase == 2 && element.getTagName().equals("way")) {
                OSMWay osmWay = new OSMWay();
                osmWay.setId(Long.parseLong(element.getAttribute("id")));
                processTags(osmWay, element);

                Node node2 = element.getFirstChild();
                while (node2 != null) {
                    if (!(node2 instanceof Element)) {
                        node2 = node2.getNextSibling();
                        continue;
                    }
                    Element element2 = (Element) node2;
                    if (element2.getNodeName().equals("nd")) {
                        OSMNodeRef nodeRef = new OSMNodeRef();
                        nodeRef.setRef(Long.parseLong(element2.getAttribute("ref")));
                        osmWay.addNodeRef(nodeRef);
                    }
                    node2 = node2.getNextSibling();
                }

                map.addWay(osmWay);
View Full Code Here

Examples of org.opentripplanner.openstreetmap.model.OSMWay

        if (waysByEndpoint.size() == 0) {
            return closedRings;
        }

        long firstEndpoint = 0, otherEndpoint = 0;
        OSMWay firstWay = null;
        for (Long endpoint : waysByEndpoint.keySet()) {
            List<OSMWay> list = waysByEndpoint.get(endpoint);
            firstWay = list.get(0);
            List<Long> nodeRefs = firstWay.getNodeRefs();
            partialRing.addAll(nodeRefs);
            firstEndpoint = nodeRefs.get(0);
            otherEndpoint = nodeRefs.get(nodeRefs.size() - 1);
            break;
        }
View Full Code Here

Examples of org.opentripplanner.openstreetmap.model.OSMWay

                    return true; // success
                }

                // otherwise, we need to start a new partial ring
                newRing = new ArrayList<Long>();
                OSMWay firstWay = null;
                for (Long entry : waysByEndpoint.keySet()) {
                    List<OSMWay> list = waysByEndpoint.get(entry);
                    firstWay = list.get(0);
                    nodeRefs = firstWay.getNodeRefs();
                    newRing.addAll(nodeRefs);
                    firstEndpoint = nodeRefs.get(0);
                    otherEndpoint = nodeRefs.get(nodeRefs.size() - 1);
                    break;
                }
View Full Code Here

Examples of org.opentripplanner.openstreetmap.model.OSMWay

        }
    }

    @Test
    public void testWayDataSet() {
        OSMWithTags way = new OSMWay();
        way.addTag("highway", "footway");
        way.addTag("cycleway", "lane");
        way.addTag("access", "no");
        way.addTag("surface", "gravel");

        WayPropertySet wayPropertySet = new WayPropertySet();

        // where there are no way specifiers, the default is used
        assertEquals(wayPropertySet.getDataForWay(way), wayPropertySet.defaultProperties);

        // add two equal matches: lane only...
        OSMSpecifier lane_only = new OSMSpecifier();
        lane_only.addTag("cycleway", "lane");

        WayProperties lane_is_safer = new WayProperties();
        lane_is_safer.setSafetyFeatures(new P2<Double>(1.5, 1.5));

        wayPropertySet.addProperties(lane_only, lane_is_safer);

        // and footway only
        OSMSpecifier footway_only = new OSMSpecifier();
        footway_only.addTag("highway", "footway");

        WayProperties footways_allow_peds = new WayProperties();
        footways_allow_peds.setPermission(StreetTraversalPermission.PEDESTRIAN);

        wayPropertySet.addProperties(footway_only, footways_allow_peds);

        WayProperties dataForWay = wayPropertySet.getDataForWay(way);
        // the first one is found
        assertEquals(dataForWay, lane_is_safer);

        // add a better match
        OSMSpecifier lane_and_footway = new OSMSpecifier();
        lane_and_footway.addTag("cycleway", "lane");
        lane_and_footway.addTag("highway", "footway");

        WayProperties safer_and_peds = new WayProperties();
        safer_and_peds.setSafetyFeatures(new P2<Double>(0.75, 0.75));
        safer_and_peds.setPermission(StreetTraversalPermission.PEDESTRIAN);

        wayPropertySet.addProperties(lane_and_footway, safer_and_peds);
        dataForWay = wayPropertySet.getDataForWay(way);
        assertEquals(dataForWay, safer_and_peds);

        // add a mixin
        OSMSpecifier gravel = new OSMSpecifier("surface=gravel");
        WayProperties gravel_is_dangerous = new WayProperties();
        gravel_is_dangerous.setSafetyFeatures(new P2<Double>(2.0, 2.0));
        wayPropertySet.addProperties(gravel, gravel_is_dangerous, true);

        dataForWay = wayPropertySet.getDataForWay(way);
        assertEquals(dataForWay.getSafetyFeatures().first, 1.5);

        // test a left-right distinction
        way = new OSMWay();
        way.addTag("highway", "footway");
        way.addTag("cycleway", "lane");
        way.addTag("cycleway:right", "track");

        OSMSpecifier track_only = new OSMSpecifier("highway=footway;cycleway=track");
        WayProperties track_is_safest = new WayProperties();
        track_is_safest.setSafetyFeatures(new P2<Double>(0.25, 0.25));

        wayPropertySet.addProperties(track_only, track_is_safest);
        dataForWay = wayPropertySet.getDataForWay(way);
        assertEquals(0.25, dataForWay.getSafetyFeatures().first); // right (with traffic) comes
                                                                       // from track
        assertEquals(0.75, dataForWay.getSafetyFeatures().second); // left comes from lane

        way = new OSMWay();
        way.addTag("highway", "footway");
        way.addTag("footway", "sidewalk");
        way.addTag("RLIS:reviewed", "no");
        WayPropertySet propset = new WayPropertySet();
        CreativeNamer namer = new CreativeNamer("platform");
        propset.addCreativeNamer(new OSMSpecifier(
                "railway=platform;highway=footway;footway=sidewalk"), namer);
        namer = new CreativeNamer("sidewalk");
View Full Code Here

Examples of org.opentripplanner.openstreetmap.model.OSMWay

        assertEquals("sidewalk", propset.getCreativeNameForWay(way));
    }

    @Test
    public void testCreativeNaming() {
        OSMWithTags way = new OSMWay();
        way.addTag("highway", "footway");
        way.addTag("cycleway", "lane");
        way.addTag("access", "no");

        CreativeNamer namer = new CreativeNamer();
        namer.setCreativeNamePattern("Highway with cycleway {cycleway} and access {access} and morx {morx}");
        assertEquals("Highway with cycleway lane and access no and morx ",
                namer.generateCreativeName(way));
View Full Code Here

Examples of org.opentripplanner.openstreetmap.model.OSMWay

        }
    }

    private void markNodesForKeeping(Collection<OSMWay> osmWays, Set<Long> nodeSet) {
        for (Iterator<OSMWay> it = osmWays.iterator(); it.hasNext();) {
            OSMWay way = it.next();
            // Since the way is kept, update nodes-with-neighbors
            List<Long> nodes = way.getNodeRefs();
            if (nodes.size() > 1) {
                nodeSet.addAll(nodes);
            }
        }
    }
View Full Code Here

Examples of org.opentripplanner.openstreetmap.model.OSMWay

            // Area multipolygons -- pedestrian plazas
            ArrayList<OSMWay> innerWays = new ArrayList<OSMWay>();
            ArrayList<OSMWay> outerWays = new ArrayList<OSMWay>();
            for (OSMRelationMember member : relation.getMembers()) {
                String role = member.getRole();
                OSMWay way = areaWaysById.get(member.getRef());
                if (way == null) {
                    // relation includes way which does not exist in the data. Skip.
                    continue RELATION;
                }
                for (Long nodeId : way.getNodeRefs()) {
                    if (!nodesById.containsKey(nodeId)) {
                        // this area is missing some nodes, perhaps because it is on
                        // the edge of the region, so we will simply not route on it.
                        continue RELATION;
                    }
                    MapUtils.addToMapSet(areasForNode, nodeId, way);
                }
                if (role.equals("inner")) {
                    innerWays.add(way);
                } else if (role.equals("outer")) {
                    outerWays.add(way);
                } else {
                    LOG.warn("Unexpected role " + role + " in multipolygon");
                }
            }
            processedAreas.add(relation);
            try {
                newArea(new Area(relation, outerWays, innerWays, nodesById));
            } catch (Area.AreaConstructionException e) {
                continue;
            }

            for (OSMRelationMember member : relation.getMembers()) {
                // multipolygons for attribute mapping
                if (!("way".equals(member.getType()) && waysById.containsKey(member.getRef()))) {
                    continue;
                }

                OSMWithTags way = waysById.get(member.getRef());
                if (way == null) {
                    continue;
                }
                String[] relationCopyTags = { "highway", "name", "ref" };
                for (String tag : relationCopyTags) {
                    if (relation.hasTag(tag) && !way.hasTag(tag)) {
                        way.addTag(tag, relation.getTag(tag));
                    }
                }
                if (relation.isTag("railway", "platform") && !way.hasTag("railway")) {
                    way.addTag("railway", "platform");
                }
                if (relation.isTag("public_transport", "platform")
                        && !way.hasTag("public_transport")) {
                    way.addTag("public_transport", "platform");
                }
            }
        }
    }
View Full Code Here

Examples of org.opentripplanner.openstreetmap.model.OSMWay

    private void processLevelMap(OSMRelation relation) {
        Map<String, OSMLevel> levels = OSMLevel.mapFromSpecList(relation.getTag("levels"),
                Source.LEVEL_MAP, true);
        for (OSMRelationMember member : relation.getMembers()) {
            if ("way".equals(member.getType()) && waysById.containsKey(member.getRef())) {
                OSMWay way = waysById.get(member.getRef());
                if (way != null) {
                    String role = member.getRole();
                    // if the level map relation has a role:xyz tag, this way is something
                    // more complicated than a single level (e.g. ramp/stairway).
                    if (!relation.hasTag("role:" + role)) {
View Full Code Here

Examples of org.opentripplanner.openstreetmap.model.OSMWay

        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"));
    }
View Full Code Here

Examples of org.osm2world.core.osm.data.OSMWay

        new OSMNode(0, 0, new MapBasedTagGroup(new Tag("power","tower")), 101),
        new OSMNode(0, 0.001, new MapBasedTagGroup(new Tag("power","tower")), 102)
        );
   
    List<OSMWay> ways = asList(
        new OSMWay(new MapBasedTagGroup(new Tag("power","line"), new Tag("cables","4")), 201, nodes)
        );
   
    OSMData osmData = new OSMData(EMPTY_LIST, nodes, ways, EMPTY_LIST);
   
    /* render to multiple targets */
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.