Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSM area processing obeys tag mapping #6164

Merged
merged 17 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from 13 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 @@ -791,9 +791,11 @@ private void processMultipolygonRelations() {
* Handler for a new Area (single way area or multipolygon relations)
*/
private void newArea(Area area) {
vesameskanen marked this conversation as resolved.
Show resolved Hide resolved
StreetTraversalPermission permissions = area.parent.overridePermissions(
StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE
);
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way vs area thing here is slightly confusing, but I think it's a common problem that we use these way properties for areas as well so if we were to rename things, we would need to rename a lot of things.

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
Loading