Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ void applyWayProperties(
boolean motorVehicleNoThrough = tagMapperForWay.isMotorVehicleThroughTrafficExplicitlyDisallowed(
way
);
boolean bicycleNoThrough = tagMapperForWay.isBicycleNoThroughTrafficExplicitlyDisallowed(way);
boolean walkNoThrough = tagMapperForWay.isWalkNoThroughTrafficExplicitlyDisallowed(way);
boolean bicycleNoThrough = tagMapperForWay.isBicycleThroughTrafficExplicitlyDisallowed(way);
boolean walkNoThrough = tagMapperForWay.isWalkThroughTrafficExplicitlyDisallowed(way);

if (street != null) {
double bicycleSafety = wayData.bicycleSafety().forward();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static org.opentripplanner.street.model.StreetTraversalPermission.PEDESTRIAN;
import static org.opentripplanner.street.model.StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE;

import java.util.Set;
import org.opentripplanner.framework.functional.FunctionUtils.TriFunction;
import org.opentripplanner.osm.model.OsmWithTags;
import org.opentripplanner.osm.wayproperty.WayPropertySet;
Expand All @@ -26,6 +27,14 @@
*/
class FinlandMapper extends OsmTagMapper {

private static final Set<String> NOTHROUGH_DRIVING_TAGS = Set.of(
"parking_aisle",
"driveway",
"alley",
"emergency_access",
"drive-through"
);

@Override
public void populateProperties(WayPropertySet props) {
TriFunction<StreetTraversalPermission, Float, OsmWithTags, Double> defaultWalkSafetyForPermission = (
Expand Down Expand Up @@ -206,7 +215,7 @@ else if (speedLimit <= 16.65f) {
}

@Override
public boolean isBicycleNoThroughTrafficExplicitlyDisallowed(OsmWithTags way) {
public boolean isBicycleThroughTrafficExplicitlyDisallowed(OsmWithTags way) {
String bicycle = way.getTag("bicycle");
return (
isVehicleThroughTrafficExplicitlyDisallowed(way) ||
Expand All @@ -215,8 +224,16 @@ public boolean isBicycleNoThroughTrafficExplicitlyDisallowed(OsmWithTags way) {
}

@Override
public boolean isWalkNoThroughTrafficExplicitlyDisallowed(OsmWithTags way) {
public boolean isWalkThroughTrafficExplicitlyDisallowed(OsmWithTags way) {
String foot = way.getTag("foot");
return isGeneralNoThroughTraffic(way) || doesTagValueDisallowThroughTraffic(foot);
}

@Override
public boolean isMotorVehicleThroughTrafficExplicitlyDisallowed(OsmWithTags way) {
if (super.isMotorVehicleThroughTrafficExplicitlyDisallowed(way)) {
return true;
}
return way.isOneOfTags("service", NOTHROUGH_DRIVING_TAGS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ public boolean isMotorVehicleThroughTrafficExplicitlyDisallowed(OsmWithTags way)
/**
* Returns true if through traffic for bicycle is not allowed.
*/
public boolean isBicycleNoThroughTrafficExplicitlyDisallowed(OsmWithTags way) {
public boolean isBicycleThroughTrafficExplicitlyDisallowed(OsmWithTags way) {
String bicycle = way.getTag("bicycle");
if (bicycle != null) {
return doesTagValueDisallowThroughTraffic(bicycle);
Expand All @@ -780,7 +780,7 @@ public boolean isBicycleNoThroughTrafficExplicitlyDisallowed(OsmWithTags way) {
/**
* Returns true if through traffic for walk is not allowed.
*/
public boolean isWalkNoThroughTrafficExplicitlyDisallowed(OsmWithTags way) {
public boolean isWalkThroughTrafficExplicitlyDisallowed(OsmWithTags way) {
String foot = way.getTag("foot");
if (foot != null) {
return doesTagValueDisallowThroughTraffic(foot);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.opentripplanner.osm.tagmapping;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;
import org.opentripplanner.osm.model.OsmWithTags;

public class ConstantSpeedMapperTest {

@Test
public void constantSpeedCarRouting() {
OsmTagMapper osmTagMapper = new ConstantSpeedFinlandMapper(20f);

var slowWay = new OsmWithTags();
slowWay.addTag("highway", "residential");
assertEquals(20f, osmTagMapper.getCarSpeedForWay(slowWay, true));

var fastWay = new OsmWithTags();
fastWay.addTag("highway", "motorway");
fastWay.addTag("maxspeed", "120 kmph");
assertEquals(20f, osmTagMapper.getCarSpeedForWay(fastWay, true));
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.opentripplanner.osm.tagmapping;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.opentripplanner.street.model.StreetTraversalPermission.NONE;
import static org.opentripplanner.street.model.StreetTraversalPermission.PEDESTRIAN;
import static org.opentripplanner.street.model.StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.opentripplanner.osm.model.OsmWay;
import org.opentripplanner.osm.model.OsmWithTags;
Expand All @@ -13,12 +15,15 @@

public class FinlandMapperTest {

static WayPropertySet wps = new WayPropertySet();
private WayPropertySet wps;
private OsmTagMapper mapper;
static float epsilon = 0.01f;

static {
var source = new FinlandMapper();
source.populateProperties(wps);
@BeforeEach
public void setup() {
this.wps = new WayPropertySet();
this.mapper = new FinlandMapper();
this.mapper.populateProperties(this.wps);
}

/**
Expand Down Expand Up @@ -220,4 +225,12 @@ public void testArea() {
wayData = wps.getDataForWay(way);
assertEquals(wayData.getPermission(), PEDESTRIAN_AND_BICYCLE);
}

@Test
public void serviceNoThroughTraffic() {
var way = new OsmWay();
way.addTag("highway", "residential");
way.addTag("service", "driveway");
assertTrue(mapper.isMotorVehicleThroughTrafficExplicitlyDisallowed(way));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,37 +34,21 @@ public void isMotorThroughTrafficExplicitlyDisallowed() {
}

@Test
public void constantSpeedCarRouting() {
OsmTagMapper osmTagMapper = new ConstantSpeedFinlandMapper(20f);

var slowWay = new OsmWithTags();
slowWay.addTag("highway", "residential");
assertEquals(20f, osmTagMapper.getCarSpeedForWay(slowWay, true));

var fastWay = new OsmWithTags();
fastWay.addTag("highway", "motorway");
fastWay.addTag("maxspeed", "120 kmph");
assertEquals(20f, osmTagMapper.getCarSpeedForWay(fastWay, true));
}

@Test
public void isBicycleNoThroughTrafficExplicitlyDisallowed() {
public void isBicycleThroughTrafficExplicitlyDisallowed() {
OsmTagMapper osmTagMapper = new OsmTagMapper();
assertTrue(
osmTagMapper.isBicycleNoThroughTrafficExplicitlyDisallowed(way("bicycle", "destination"))
osmTagMapper.isBicycleThroughTrafficExplicitlyDisallowed(way("bicycle", "destination"))
);
assertTrue(
osmTagMapper.isBicycleNoThroughTrafficExplicitlyDisallowed(way("access", "destination"))
osmTagMapper.isBicycleThroughTrafficExplicitlyDisallowed(way("access", "destination"))
);
}

@Test
public void isWalkNoThroughTrafficExplicitlyDisallowed() {
public void isWalkThroughTrafficExplicitlyDisallowed() {
OsmTagMapper osmTagMapper = new OsmTagMapper();
assertTrue(osmTagMapper.isWalkNoThroughTrafficExplicitlyDisallowed(way("foot", "destination")));
assertTrue(
osmTagMapper.isWalkNoThroughTrafficExplicitlyDisallowed(way("access", "destination"))
);
assertTrue(osmTagMapper.isWalkThroughTrafficExplicitlyDisallowed(way("foot", "destination")));
assertTrue(osmTagMapper.isWalkThroughTrafficExplicitlyDisallowed(way("access", "destination")));
}

@Test
Expand All @@ -75,8 +59,8 @@ public void testAccessNo() {
tags.addTag("access", "no");

assertTrue(osmTagMapper.isMotorVehicleThroughTrafficExplicitlyDisallowed(tags));
assertTrue(osmTagMapper.isBicycleNoThroughTrafficExplicitlyDisallowed(tags));
assertTrue(osmTagMapper.isWalkNoThroughTrafficExplicitlyDisallowed(tags));
assertTrue(osmTagMapper.isBicycleThroughTrafficExplicitlyDisallowed(tags));
assertTrue(osmTagMapper.isWalkThroughTrafficExplicitlyDisallowed(tags));
}

@Test
Expand All @@ -87,8 +71,8 @@ public void testAccessPrivate() {
tags.addTag("access", "private");

assertTrue(osmTagMapper.isMotorVehicleThroughTrafficExplicitlyDisallowed(tags));
assertTrue(osmTagMapper.isBicycleNoThroughTrafficExplicitlyDisallowed(tags));
assertTrue(osmTagMapper.isWalkNoThroughTrafficExplicitlyDisallowed(tags));
assertTrue(osmTagMapper.isBicycleThroughTrafficExplicitlyDisallowed(tags));
assertTrue(osmTagMapper.isWalkThroughTrafficExplicitlyDisallowed(tags));
}

@Test
Expand All @@ -100,8 +84,8 @@ public void testFootModifier() {
tags.addTag("foot", "yes");

assertTrue(osmTagMapper.isMotorVehicleThroughTrafficExplicitlyDisallowed(tags));
assertTrue(osmTagMapper.isBicycleNoThroughTrafficExplicitlyDisallowed(tags));
assertFalse(osmTagMapper.isWalkNoThroughTrafficExplicitlyDisallowed(tags));
assertTrue(osmTagMapper.isBicycleThroughTrafficExplicitlyDisallowed(tags));
assertFalse(osmTagMapper.isWalkThroughTrafficExplicitlyDisallowed(tags));
}

@Test
Expand All @@ -112,8 +96,8 @@ public void testVehicleDenied() {
tags.addTag("vehicle", "destination");

assertTrue(osmTagMapper.isMotorVehicleThroughTrafficExplicitlyDisallowed(tags));
assertTrue(osmTagMapper.isBicycleNoThroughTrafficExplicitlyDisallowed(tags));
assertFalse(osmTagMapper.isWalkNoThroughTrafficExplicitlyDisallowed(tags));
assertTrue(osmTagMapper.isBicycleThroughTrafficExplicitlyDisallowed(tags));
assertFalse(osmTagMapper.isWalkThroughTrafficExplicitlyDisallowed(tags));
}

@Test
Expand All @@ -125,8 +109,8 @@ public void testVehicleDeniedMotorVehiclePermissive() {
tags.addTag("motor_vehicle", "designated");

assertFalse(osmTagMapper.isMotorVehicleThroughTrafficExplicitlyDisallowed(tags));
assertTrue(osmTagMapper.isBicycleNoThroughTrafficExplicitlyDisallowed(tags));
assertFalse(osmTagMapper.isWalkNoThroughTrafficExplicitlyDisallowed(tags));
assertTrue(osmTagMapper.isBicycleThroughTrafficExplicitlyDisallowed(tags));
assertFalse(osmTagMapper.isWalkThroughTrafficExplicitlyDisallowed(tags));
}

@Test
Expand All @@ -138,8 +122,8 @@ public void testVehicleDeniedBicyclePermissive() {
tags.addTag("bicycle", "designated");

assertTrue(osmTagMapper.isMotorVehicleThroughTrafficExplicitlyDisallowed(tags));
assertFalse(osmTagMapper.isBicycleNoThroughTrafficExplicitlyDisallowed(tags));
assertFalse(osmTagMapper.isWalkNoThroughTrafficExplicitlyDisallowed(tags));
assertFalse(osmTagMapper.isBicycleThroughTrafficExplicitlyDisallowed(tags));
assertFalse(osmTagMapper.isWalkThroughTrafficExplicitlyDisallowed(tags));
}

@Test
Expand All @@ -151,8 +135,8 @@ public void testMotorcycleModifier() {
tags.addTag("motor_vehicle", "yes");

assertFalse(osmTagMapper.isMotorVehicleThroughTrafficExplicitlyDisallowed(tags));
assertTrue(osmTagMapper.isBicycleNoThroughTrafficExplicitlyDisallowed(tags));
assertTrue(osmTagMapper.isWalkNoThroughTrafficExplicitlyDisallowed(tags));
assertTrue(osmTagMapper.isBicycleThroughTrafficExplicitlyDisallowed(tags));
assertTrue(osmTagMapper.isWalkThroughTrafficExplicitlyDisallowed(tags));
}

@Test
Expand All @@ -164,8 +148,8 @@ public void testBicycleModifier() {
tags.addTag("bicycle", "yes");

assertTrue(osmTagMapper.isMotorVehicleThroughTrafficExplicitlyDisallowed(tags));
assertFalse(osmTagMapper.isBicycleNoThroughTrafficExplicitlyDisallowed(tags));
assertTrue(osmTagMapper.isWalkNoThroughTrafficExplicitlyDisallowed(tags));
assertFalse(osmTagMapper.isBicycleThroughTrafficExplicitlyDisallowed(tags));
assertTrue(osmTagMapper.isWalkThroughTrafficExplicitlyDisallowed(tags));
}

@Test
Expand All @@ -177,8 +161,8 @@ public void testBicyclePermissive() {
tags.addTag("bicycle", "permissive");

assertTrue(osmTagMapper.isMotorVehicleThroughTrafficExplicitlyDisallowed(tags));
assertFalse(osmTagMapper.isBicycleNoThroughTrafficExplicitlyDisallowed(tags));
assertTrue(osmTagMapper.isWalkNoThroughTrafficExplicitlyDisallowed(tags));
assertFalse(osmTagMapper.isBicycleThroughTrafficExplicitlyDisallowed(tags));
assertTrue(osmTagMapper.isWalkThroughTrafficExplicitlyDisallowed(tags));
}

public OsmWithTags way(String key, String value) {
Expand Down
Loading