Skip to content

Commit

Permalink
Merge pull request #6164 from HSLdevcom/area-permissions
Browse files Browse the repository at this point in the history
OSM area processing obeys tag mapping
  • Loading branch information
vesameskanen authored Nov 8, 2024
2 parents 20b7888 + e6d383b commit f5466e8
Show file tree
Hide file tree
Showing 21 changed files with 849 additions and 843 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ private void processSingleWayAreas() {
}
}
try {
newArea(new Area(way, List.of(way), Collections.emptyList(), nodesById));
addArea(new Area(way, List.of(way), Collections.emptyList(), nodesById));
} catch (Area.AreaConstructionException | Ring.RingConstructionException e) {
// this area cannot be constructed, but we already have all the
// necessary nodes to construct it. So, something must be wrong with
Expand Down Expand Up @@ -751,7 +751,7 @@ private void processMultipolygonRelations() {
}
processedAreas.add(relation);
try {
newArea(new Area(relation, outerWays, innerWays, nodesById));
addArea(new Area(relation, outerWays, innerWays, nodesById));
} catch (Area.AreaConstructionException | Ring.RingConstructionException e) {
issueStore.add(new InvalidOsmGeometry(relation));
continue;
Expand Down Expand Up @@ -786,10 +786,12 @@ private void processMultipolygonRelations() {
/**
* Handler for a new Area (single way area or multipolygon relations)
*/
private void newArea(Area area) {
StreetTraversalPermission permissions = area.parent.overridePermissions(
StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE
);
private void addArea(Area area) {
StreetTraversalPermission permissions = area.parent
.getOsmProvider()
.getWayPropertySet()
.getDataForWay(area.parent)
.getPermission();
if (area.parent.isRoutable() && permissions != StreetTraversalPermission.NONE) {
walkableAreas.add(area);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,14 @@ private Set<AreaEdge> createSegments(
Area area = intersects.getFirst();
OsmWithTags areaEntity = area.parent;

StreetTraversalPermission areaPermissions = areaEntity.overridePermissions(
StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE
);
WayProperties wayData;
if (!wayPropertiesCache.containsKey(areaEntity)) {
wayData = areaEntity.getOsmProvider().getWayPropertySet().getDataForWay(areaEntity);
wayPropertiesCache.put(areaEntity, wayData);
} else {
wayData = wayPropertiesCache.get(areaEntity);
}
StreetTraversalPermission areaPermissions = wayData.getPermission();

float carSpeed = areaEntity
.getOsmProvider()
Expand All @@ -520,8 +525,8 @@ private Set<AreaEdge> createSegments(
startEndpoint.getLabel() +
" to " +
endEndpoint.getLabel();
I18NString name = namer.getNameForWay(areaEntity, label);

I18NString name = namer.getNameForWay(areaEntity, label);
AreaEdgeBuilder streetEdgeBuilder = new AreaEdgeBuilder()
.withFromVertex(startEndpoint)
.withToVertex(endEndpoint)
Expand All @@ -543,8 +548,8 @@ private Set<AreaEdge> createSegments(
endEndpoint.getLabel() +
" to " +
startEndpoint.getLabel();
name = namer.getNameForWay(areaEntity, label);

name = namer.getNameForWay(areaEntity, label);
AreaEdgeBuilder backStreetEdgeBuilder = new AreaEdgeBuilder()
.withFromVertex(endEndpoint)
.withToVertex(startEndpoint)
Expand All @@ -559,22 +564,10 @@ private Set<AreaEdge> createSegments(
.withWheelchairAccessible(areaEntity.isWheelchairAccessible())
.withLink(areaEntity.isLink());

if (!wayPropertiesCache.containsKey(areaEntity)) {
WayProperties wayData = areaEntity
.getOsmProvider()
.getWayPropertySet()
.getDataForWay(areaEntity);
wayPropertiesCache.put(areaEntity, wayData);
}

AreaEdge street = streetEdgeBuilder.buildAndConnect();

AreaEdge backStreet = backStreetEdgeBuilder.buildAndConnect();
normalizer.applyWayProperties(
street,
backStreet,
wayPropertiesCache.get(areaEntity),
areaEntity
);
normalizer.applyWayProperties(street, backStreet, wayData, areaEntity);
return Set.of(street, backStreet);
} else {
// take the part that intersects with the start vertex
Expand Down Expand Up @@ -640,27 +633,21 @@ private void createNamedAreas(AreaEdgeList edgeList, Ring ring, Collection<Area>
I18NString name = namer.getNameForWay(areaEntity, id);
namedArea.setName(name);

WayProperties wayData;
if (!wayPropertiesCache.containsKey(areaEntity)) {
WayProperties wayData = areaEntity
.getOsmProvider()
.getWayPropertySet()
.getDataForWay(areaEntity);
wayData = areaEntity.getOsmProvider().getWayPropertySet().getDataForWay(areaEntity);
wayPropertiesCache.put(areaEntity, wayData);
} else {
wayData = wayPropertiesCache.get(areaEntity);
}

double bicycleSafety = wayPropertiesCache.get(areaEntity).bicycleSafety().forward();
namedArea.setBicycleSafetyMultiplier(bicycleSafety);

double walkSafety = wayPropertiesCache.get(areaEntity).walkSafety().forward();
namedArea.setWalkSafetyMultiplier(walkSafety);

namedArea.setOriginalEdges(intersection);

StreetTraversalPermission permission = areaEntity.overridePermissions(
StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE
);
namedArea.setPermission(permission);

namedArea.setPermission(wayData.getPermission());
edgeList.addArea(namedArea);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
*
* @author demory
* @see OsmTagMapper
* @see DefaultMapper
*/

class AtlantaMapper implements OsmTagMapper {
class AtlantaMapper extends OsmTagMapper {

@Override
public void populateProperties(WayPropertySet props) {
Expand All @@ -27,7 +26,6 @@ public void populateProperties(WayPropertySet props) {
// Max speed limit in Georgia is 70 mph ~= 113kmh ~= 31.3m/s
props.maxPossibleCarSpeed = 31.4f;

// Read the rest from the default set
new DefaultMapper().populateProperties(props);
super.populateProperties(props);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* OSM way properties for optimizing distance (not traveling time) in routing.
*/
class ConstantSpeedFinlandMapper implements OsmTagMapper {
class ConstantSpeedFinlandMapper extends FinlandMapper {

private float speed;

Expand All @@ -23,8 +23,7 @@ public ConstantSpeedFinlandMapper(float speed) {
@Override
public void populateProperties(WayPropertySet props) {
props.setCarSpeed("highway=*", speed);
// Read the rest from the default set
new FinlandMapper().populateProperties(props);
super.populateProperties(props);
props.maxPossibleCarSpeed = speed;
}

Expand Down
Loading

0 comments on commit f5466e8

Please sign in to comment.