restrict direction cones to matching parent ways, fixes #9013

for certain vertex features, only look at matching parent ways when determining where to draw direction cones:

* highway related points (e.g. highway=stop/yield/etc., traffic calming, cycleway=asl, traffic signs, barriers): only look at parent ways with highway=*
* railway related points (e.g. railway=milestone): only look at parent ways with railway=*
* waterway related points (e.g. waterway=milestone): only look at parent ways with waterway=*

see also #5634
This commit is contained in:
Martin Raifer
2024-12-04 13:33:33 +01:00
parent 04fd2ba6f4
commit 3be7eb6fca
2 changed files with 17 additions and 11 deletions

View File

@@ -114,19 +114,23 @@ Object.assign(osmNode.prototype, {
if (!lookForward && !lookBackward) return;
var nodeIds = {};
resolver.parentWays(this).forEach(function(parent) {
var nodes = parent.nodes;
for (i = 0; i < nodes.length; i++) {
if (nodes[i] === this.id) { // match current entity
if (lookForward && i > 0) {
nodeIds[nodes[i - 1]] = true; // look back to prev node
}
if (lookBackward && i < nodes.length - 1) {
nodeIds[nodes[i + 1]] = true; // look ahead to next node
resolver.parentWays(this)
.filter(p => (this.tags.highway || this.tags.traffic_sign || this.tags.traffic_calming || this.tags.barrier || this.tags.cycleway) ? p.tags.highway : true)
.filter(p => (this.tags.railway) ? p.tags.railway : true)
.filter(p => (this.tags.waterway) ? p.tags.waterway : true)
.forEach(function(parent) {
var nodes = parent.nodes;
for (i = 0; i < nodes.length; i++) {
if (nodes[i] === this.id) { // match current entity
if (lookForward && i > 0) {
nodeIds[nodes[i - 1]] = true; // look back to prev node
}
if (lookBackward && i < nodes.length - 1) {
nodeIds[nodes[i + 1]] = true; // look ahead to next node
}
}
}
}
}, this);
}, this);
Object.keys(nodeIds).forEach(function(nodeId) {
// +90 because geoAngle returns angle from X axis, not Y (north)