public class CaseBasedTraversalPermissionConverter extends Object implements SimpleFeatureConverter<P2<StreetTraversalPermission>>
| DIRECTION | NAME | | ONE_WAY_F | Side St | | TWO_WAY | Main St | | ONE_WAY_B | Foo St. |You could use a CaseBasedTraversalPermissionConverter to implement the following rules:
By default, all streets should be traversable by pedestrians and bicycles in both directions.
If a street's DIRECTION attribute is ONE_WAY_F, it should be traversable by cars and bikes in only the forward direction and traversable by pedestrians in both directions.
If a street's DIRECTION attribute is ONE_WAY_B, it should be traversable by cars and bikes in only the backward direction and traversable by pedestrians in both directions.
If a street's DIRECTION attribute is TWO_WAY, it should be traversable by everyone in both directions.
These rules could be implemented by configuring the converter bean as follows:
<bean class="org.opentripplanner.graph_builder.module.shapefile.CaseBasedTraversalPermissionConverter">
<property name="attributeName" value="DIRECTION" />
<property name="defaultPermission" value="PEDESTRIAN_AND_BICYCLE" />
<property name="permissions">
<map>
<entry key="ONE_WAY_F" value="PEDESTRIAN,ALL" />
<entry key="ONE_WAY_B" value="ALL,PEDESTRIAN" />
<entry key="TWO_WAY" value="ALL,ALL" />
</map>
</property>
</bean>
StreetTraversalPermission
Constructor and Description |
---|
CaseBasedTraversalPermissionConverter() |
CaseBasedTraversalPermissionConverter(String attributeName) |
CaseBasedTraversalPermissionConverter(String attributeName,
StreetTraversalPermission defaultPermission) |
Modifier and Type | Method and Description |
---|---|
void |
addPermission(String attributeValue,
StreetTraversalPermission forward,
StreetTraversalPermission reverse) |
P2<StreetTraversalPermission> |
convert(org.opengis.feature.simple.SimpleFeature feature) |
void |
setAttributeName(String attributeName)
The name of the feature attribute to use when calculating the traversal permissions.
|
void |
setDefaultPermission(StreetTraversalPermission permission)
The default permission to use when no matching case is found for a street.
|
void |
setPermissions(Map<String,String> permissions)
The mapping from attribute values to permissions to use when determining a street's traversal
permission.
|
public CaseBasedTraversalPermissionConverter()
public CaseBasedTraversalPermissionConverter(String attributeName)
public CaseBasedTraversalPermissionConverter(String attributeName, StreetTraversalPermission defaultPermission)
public void setAttributeName(String attributeName)
public void setDefaultPermission(StreetTraversalPermission permission)
public void setPermissions(Map<String,String> permissions)
public void addPermission(String attributeValue, StreetTraversalPermission forward, StreetTraversalPermission reverse)
public P2<StreetTraversalPermission> convert(org.opengis.feature.simple.SimpleFeature feature)
convert
in interface SimpleFeatureConverter<P2<StreetTraversalPermission>>
Copyright © 2019. All rights reserved.