-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
automatically create pedestrian crossing line when joining sidewalk/road #10524
Open
k-yle
wants to merge
1
commit into
develop
Choose a base branch
from
kh/crossing-connection
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -476,6 +476,28 @@ export function validationCrossingWays(context) { | |
if (allowsTunnel(selectedFeatureType) && !skipTunnelFix) { | ||
fixes.push(makeAddBridgeOrTunnelFix('add_a_tunnel', 'temaki-tunnel', 'tunnel')); | ||
} | ||
|
||
// special case: if | ||
// (1) we're about to join these lines with a highway=crossing node; and | ||
// (2) one of the lines is a sidewalk | ||
// then we will split the sidewalk and create a highway=crossing way | ||
const isSidewalk = ( | ||
entities[0].tags.footway === 'sidewalk' || | ||
entities[1].tags.footway === 'sidewalk' || | ||
entities[0].tags.cycleway === 'sidewalk' || | ||
entities[1].tags.cycleway === 'sidewalk' | ||
); | ||
if (connectionTags.highway === 'crossing' && isSidewalk) { | ||
const newAction = makeAddBridgeOrTunnelFix( | ||
'connect_using_crossing', | ||
'temaki-pedestrian', | ||
'crossing', | ||
connectionTags | ||
); | ||
// replace the default action with this action | ||
fixes = fixes.filter(action => action.id !== newAction.id); | ||
fixes.unshift(newAction); | ||
} | ||
} | ||
|
||
// repositioning the features is always an option | ||
|
@@ -498,7 +520,13 @@ export function validationCrossingWays(context) { | |
} | ||
} | ||
|
||
function makeAddBridgeOrTunnelFix(fixTitleID, iconName, bridgeOrTunnel){ | ||
/** | ||
* @param {string} fixTitleID | ||
* @param {string} iconName | ||
* @param {'bridge' | 'tunnel' | 'crossing'} crossingType | ||
* @param {Tags=} connectionTags | ||
*/ | ||
function makeAddBridgeOrTunnelFix(fixTitleID, iconName, crossingType, connectionTags){ | ||
return new validationIssueFix({ | ||
icon: iconName, | ||
title: t.append('issues.fix.' + fixTitleID + '.title'), | ||
|
@@ -678,20 +706,35 @@ export function validationCrossingWays(context) { | |
}); | ||
|
||
var tags = Object.assign({}, structureWay.tags); // copy tags | ||
if (bridgeOrTunnel === 'bridge'){ | ||
if (crossingType === 'bridge'){ | ||
tags.bridge = 'yes'; | ||
tags.layer = '1'; | ||
} else { | ||
} else if (crossingType === 'tunnel') { | ||
var tunnelValue = 'yes'; | ||
if (getFeatureType(structureWay, graph) === 'waterway') { | ||
// use `tunnel=culvert` for waterways by default | ||
tunnelValue = 'culvert'; | ||
} | ||
tags.tunnel = tunnelValue; | ||
tags.layer = '-1'; | ||
} else if (crossingType === 'crossing') { | ||
// we know that the line will already have | ||
// `footway=sidewalk` or `cycleway=sidewalk` | ||
tags[tags.footway ? 'footway' : 'cycleway'] = 'crossing'; | ||
} | ||
|
||
// apply the structure tags to the way | ||
graph = actionChangeTags(structureWay.id, tags)(graph); | ||
|
||
// for crossing, we also need to join the two lines | ||
if (crossingType === 'crossing') { | ||
const edgesToJoin = [ | ||
[structEndNode1.id, structEndNode2.id], | ||
crossedEdge, | ||
]; | ||
graph = actionConnectCrossingWays(crossingLoc, edgesToJoin, connectionTags)(graph); | ||
} | ||
|
||
return graph; | ||
}; | ||
|
||
|
@@ -701,6 +744,42 @@ export function validationCrossingWays(context) { | |
}); | ||
} | ||
|
||
/** | ||
* @param {[number, number]} loc | ||
* @param {[string, string][]} edges | ||
* @param {Tags} connectionTags | ||
*/ | ||
function actionConnectCrossingWays(loc, edges, connectionTags) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this function is not new, if you click hide whitespace changes, then the github UI understands that this function was simply deindented & moved 20 lines up. |
||
return (graph) => { | ||
// create the new node for the points | ||
var node = osmNode({ loc: loc, tags: connectionTags }); | ||
graph = graph.replace(node); | ||
|
||
var nodesToMerge = [node.id]; | ||
var mergeThresholdInMeters = 0.75; | ||
|
||
edges.forEach(function(edge) { | ||
var edgeNodes = [graph.entity(edge[0]), graph.entity(edge[1])]; | ||
var nearby = geoSphericalClosestNode(edgeNodes, loc); | ||
// if there is already a suitable node nearby, use that | ||
// use the node if node has no interesting tags or if it is a crossing node #8326 | ||
if ((!nearby.node.hasInterestingTags() || nearby.node.isCrossing()) && nearby.distance < mergeThresholdInMeters) { | ||
nodesToMerge.push(nearby.node.id); | ||
// else add the new node to the way | ||
} else { | ||
graph = actionAddMidpoint({loc: loc, edge: edge}, node)(graph); | ||
} | ||
}); | ||
|
||
if (nodesToMerge.length > 1) { | ||
// if we're using nearby nodes, merge them with the new node | ||
graph = actionMergeNodes(nodesToMerge, loc)(graph); | ||
} | ||
|
||
return graph; | ||
}; | ||
} | ||
|
||
function makeConnectWaysFix(connectionTags) { | ||
|
||
var fixTitleID = 'connect_features'; | ||
|
@@ -718,38 +797,8 @@ export function validationCrossingWays(context) { | |
icon: fixIcon, | ||
title: t.append('issues.fix.' + fixTitleID + '.title'), | ||
onClick: function(context) { | ||
var loc = this.issue.loc; | ||
var edges = this.issue.data.edges; | ||
|
||
context.perform( | ||
function actionConnectCrossingWays(graph) { | ||
// create the new node for the points | ||
var node = osmNode({ loc: loc, tags: connectionTags }); | ||
graph = graph.replace(node); | ||
|
||
var nodesToMerge = [node.id]; | ||
var mergeThresholdInMeters = 0.75; | ||
|
||
edges.forEach(function(edge) { | ||
var edgeNodes = [graph.entity(edge[0]), graph.entity(edge[1])]; | ||
var nearby = geoSphericalClosestNode(edgeNodes, loc); | ||
// if there is already a suitable node nearby, use that | ||
// use the node if node has no interesting tags or if it is a crossing node #8326 | ||
if ((!nearby.node.hasInterestingTags() || nearby.node.isCrossing()) && nearby.distance < mergeThresholdInMeters) { | ||
nodesToMerge.push(nearby.node.id); | ||
// else add the new node to the way | ||
} else { | ||
graph = actionAddMidpoint({loc: loc, edge: edge}, node)(graph); | ||
} | ||
}); | ||
|
||
if (nodesToMerge.length > 1) { | ||
// if we're using nearby nodes, merge them with the new node | ||
graph = actionMergeNodes(nodesToMerge, loc)(graph); | ||
} | ||
|
||
return graph; | ||
}, | ||
actionConnectCrossingWays(this.issue.loc, this.issue.data.edges, connectionTags), | ||
t('issues.fix.connect_crossing_features.annotation') | ||
); | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this part needs more discussion, currently it only applies to
footway=sidewalk
andcycleway=sidewalk
.I think it would make sense to apply this autofix to any
highway=X
whereX=crossing
is a valid tag. This means it would apply tofootway
,cycleway
,bridleway
, andpath