Examples of OSMWithTags


Examples of org.opentripplanner.openstreetmap.model.OSMWithTags

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

            OSMWithTags way = waysById.get(member.getRef());
            if (way == null) {
                continue;
            }

            if (relation.hasTag("name")) {
                if (way.hasTag("otp:route_name")) {
                    way.addTag("otp:route_name",
                            addUniqueName(way.getTag("otp:route_name"), relation.getTag("name")));
                } else {
                    way.addTag(new OSMTag("otp:route_name", relation.getTag("name")));
                }
            }
            if (relation.hasTag("ref")) {
                if (way.hasTag("otp:route_ref")) {
                    way.addTag("otp:route_ref",
                            addUniqueName(way.getTag("otp:route_ref"), relation.getTag("ref")));
                } else {
                    way.addTag(new OSMTag("otp:route_ref", relation.getTag("ref")));
                }
            }
        }
    }
View Full Code Here

Examples of org.opentripplanner.openstreetmap.model.OSMWithTags

     * @param relation
     * @author hannesj
     * @see "http://wiki.openstreetmap.org/wiki/Tag:public_transport%3Dstop_area"
     */
    private void processPublicTransportStopArea(OSMRelation relation) {
        OSMWithTags platformArea = null;
        Set<OSMNode> platformsNodes = new HashSet<>();
        for (OSMRelationMember member : relation.getMembers()) {
            if ("way".equals(member.getType()) && "platform".equals(member.getRole())
                    && areaWayIds.contains(member.getRef())) {
                if (platformArea == null)
View Full Code Here

Examples of org.opentripplanner.openstreetmap.model.OSMWithTags

            edgeList.setOriginalEdges(ring.toJtsPolygon());

            createNamedAreas(edgeList, ring, group.areas);

            OSMWithTags areaEntity = group.getSomeOSMObject();

            for (int i = 0; i < visibilityNodes.size(); ++i) {
                OSMNode nodeI = visibilityNodes.get(i);
                VisibilityPolygon visibilityPolygon = new VisibilityPolygon(
                        visibilityPoints.get(i), areaEnv, VISIBILITY_EPSILON);
View Full Code Here

Examples of org.opentripplanner.openstreetmap.model.OSMWithTags

            return;
        }
        // do we need to recurse?
        if (intersects.size() == 1) {
            Area area = intersects.get(0);
            OSMWithTags areaEntity = area.parent;

            StreetTraversalPermission areaPermissions = OSMFilter.getPermissionsForEntity(
                    areaEntity, StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE);

            float carSpeed = wayPropertySet.getCarSpeedForWay(areaEntity, false);

            double length = distanceLibrary.distance(startEndpoint.getCoordinate(),
                    endEndpoint.getCoordinate());

            int cls = StreetEdge.CLASS_OTHERPATH;
            cls |= OSMFilter.getStreetClasses(areaEntity);

            String label = "way (area) " + areaEntity.getId() + " from " + startEndpoint.getLabel()
                    + " to " + endEndpoint.getLabel();
            String name = __handler.getNameForWay(areaEntity, label);

            AreaEdge street = edgeFactory.createAreaEdge(startEndpoint, endEndpoint, line, name,
                    length, areaPermissions, false, edgeList);
            street.setCarSpeed(carSpeed);

            if (!areaEntity.hasTag("name") && !areaEntity.hasTag("ref")) {
                street.setHasBogusName(true);
            }

            if (areaEntity.isTagFalse("wheelchair")) {
                street.setWheelchairAccessible(false);
            }

            street.setStreetClass(cls);
            edges.add(street);

            label = "way (area) " + areaEntity.getId() + " from " + endEndpoint.getLabel() + " to "
                    + startEndpoint.getLabel();
            name = __handler.getNameForWay(areaEntity, label);

            AreaEdge backStreet = edgeFactory.createAreaEdge(endEndpoint, startEndpoint,
                    (LineString) line.reverse(), name, length, areaPermissions, true, edgeList);
            backStreet.setCarSpeed(carSpeed);

            if (!areaEntity.hasTag("name") && !areaEntity.hasTag("ref")) {
                backStreet.setHasBogusName(true);
            }

            if (areaEntity.isTagFalse("wheelchair")) {
                street.setWheelchairAccessible(false);
            }

            backStreet.setStreetClass(cls);
            edges.add(backStreet);
View Full Code Here

Examples of org.opentripplanner.openstreetmap.model.OSMWithTags

            Geometry intersection = containingArea.intersection(area.toJTSMultiPolygon());
            if (intersection.getArea() == 0) {
                continue;
            }
            NamedArea namedArea = new NamedArea();
            OSMWithTags areaEntity = area.parent;
            int cls = StreetEdge.CLASS_OTHERPATH;
            cls |= OSMFilter.getStreetClasses(areaEntity);
            namedArea.setStreetClass(cls);

            String id = "way (area) " + areaEntity.getId() + " (splitter linking)";
            String name = __handler.getNameForWay(areaEntity, id);
            namedArea.setName(name);

            WayProperties wayData = wayPropertySet.getDataForWay(areaEntity);
            Double safety = wayData.getSafetyFeatures().first;
View Full Code Here

Examples of org.opentripplanner.openstreetmap.model.OSMWithTags

        }
    }

    @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.OSMWithTags

        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.OSMWithTags

                // 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.OSMWithTags

    @Test
    public void testCarSpeeds () {
       DefaultWayPropertySetSource source = new DefaultWayPropertySetSource();
       WayPropertySet wps = source.getWayPropertySet();
      
       OSMWithTags way;
      
       float epsilon = 0.01f;
      
       way = new OSMWithTags();
       way.addTag("maxspeed", "60");
       assertTrue(within(kmhAsMs(60), wps.getCarSpeedForWay(way, false), epsilon));
       assertTrue(within(kmhAsMs(60), wps.getCarSpeedForWay(way, true), epsilon));
      
       way = new OSMWithTags();
       way.addTag("maxspeed:forward", "80");
       way.addTag("maxspeed:reverse", "20");
       way.addTag("maxspeed", "40");
       assertTrue(within(kmhAsMs(80), wps.getCarSpeedForWay(way, false), epsilon));
       assertTrue(within(kmhAsMs(20), wps.getCarSpeedForWay(way, true), epsilon));
      
       way = new OSMWithTags();
       way.addTag("maxspeed", "40");
       way.addTag("maxspeed:lanes", "60|80|40");
       assertTrue(within(kmhAsMs(80), wps.getCarSpeedForWay(way, false), epsilon));
       assertTrue(within(kmhAsMs(80), wps.getCarSpeedForWay(way, true), epsilon));
      
       way = new OSMWithTags();
       way.addTag("maxspeed", "20");
       way.addTag("maxspeed:motorcar", "80");
       assertTrue(within(kmhAsMs(80), wps.getCarSpeedForWay(way, false), epsilon));
       assertTrue(within(kmhAsMs(80), wps.getCarSpeedForWay(way, true), epsilon));
      
       // test with english units
       way = new OSMWithTags();
       way.addTag("maxspeed", "35 mph");
       assertTrue(within(kmhAsMs(35 * 1.609f), wps.getCarSpeedForWay(way, false), epsilon));
       assertTrue(within(kmhAsMs(35 * 1.609f), wps.getCarSpeedForWay(way, true), epsilon));
      
       // test with no maxspeed tags
       wps = new WayPropertySet();
       wps.addSpeedPicker(getSpeedPicker("highway=motorway", kmhAsMs(100)));
       wps.addSpeedPicker(getSpeedPicker("highway=*", kmhAsMs(35)));
       wps.addSpeedPicker(getSpeedPicker("surface=gravel", kmhAsMs(10)));
       wps.defaultSpeed = kmhAsMs(25);
      
       way = new OSMWithTags();
    
       // test default speeds
       assertTrue(within(kmhAsMs(25), wps.getCarSpeedForWay(way, false), epsilon));
       assertTrue(within(kmhAsMs(25), wps.getCarSpeedForWay(way, true), epsilon));
      
       way.addTag("highway", "tertiary");
       assertTrue(within(kmhAsMs(35), wps.getCarSpeedForWay(way, false), epsilon));
       assertTrue(within(kmhAsMs(35), wps.getCarSpeedForWay(way, true), epsilon));
      
       way = new OSMWithTags();
       way.addTag("surface", "gravel");
       assertTrue(within(kmhAsMs(10), wps.getCarSpeedForWay(way, false), epsilon));
       assertTrue(within(kmhAsMs(10), wps.getCarSpeedForWay(way, true), epsilon));
      
       way = new OSMWithTags();
       way.addTag("highway", "motorway");
       assertTrue(within(kmhAsMs(100), wps.getCarSpeedForWay(way, false), epsilon));
       assertTrue(within(kmhAsMs(100), wps.getCarSpeedForWay(way, true), epsilon));
      
       // make sure that 0-speed ways can't exist
       way = new OSMWithTags();
       way.addTag("maxspeed", "0");
       assertTrue(within(kmhAsMs(25), wps.getCarSpeedForWay(way, false), epsilon));
       assertTrue(within(kmhAsMs(25), wps.getCarSpeedForWay(way, true), epsilon));
    }
View Full Code Here

Examples of org.opentripplanner.openstreetmap.model.OSMWithTags

* @author laurent
*/
public class TestTemplateLibrary extends TestCase {

    public void testTemplate() {
        OSMWithTags osmTags = new OSMWithTags();
        osmTags.addTag("note", "Note EN");
        osmTags.addTag("description:fr", "Description FR");
        osmTags.addTag("wheelchair:description", "Wheelchair description EN");
        osmTags.addTag("wheelchair:description:fr", "Wheelchair description FR");

        assertEquals(null, TemplateLibrary.generate(null, osmTags));
        assertEquals("", TemplateLibrary.generate("", osmTags));
        assertEquals("Static text", TemplateLibrary.generate("Static text", osmTags));
        assertEquals("Note: Note EN", TemplateLibrary.generate("Note: {note}", osmTags));
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.