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