Skip to content

Commit

Permalink
Allow the outdated_tags validator to upgrade standalone crossing nodes
Browse files Browse the repository at this point in the history
This validator can perform preset upgrades on standalone crossing nodes
  that are NOT attached to a parent crossing way.

If the crossing is: 1. a way or 2. a node attached to a parent crossing way, bail out.
The `ambiguous_crossing_tags` validator will take care of them.

(i.e. that parent way is the thing that will get validated thoroughly)
  • Loading branch information
bhousel committed Dec 22, 2023
1 parent 26d1740 commit c952ee9
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions modules/validations/outdated_tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import { osmIsOldMultipolygonOuterMember, osmOldMultipolygonOuterMemberOfRelatio
import { ValidationIssue, ValidationFix } from '../core/lib';


const pathVals = new Set([
'path', 'footway', 'cycleway', 'bridleway', 'pedestrian'
]);


export function validationOutdatedTags(context) {
const type = 'outdated_tags';
const dataloader = context.systems.dataloader;
Expand All @@ -24,6 +29,23 @@ export function validationOutdatedTags(context) {
.finally(() => _waitingForDeprecated = false);


/**
* _isCrossingWay
* Is the way tagged with something that would indicate that it is a crossing,
* for example `highway=footway`+`footway=crossing` ?
* @param {Object} tags - tags to check
* @return {boolean} `true` if the way is tagged as a crossing
*/
function _isCrossingWay(tags) {
for (const k of pathVals) {
if (tags.highway === k && tags[k] === 'crossing') {
return true;
}
}
return false;
}


/**
* oldTagIssues
*/
Expand All @@ -33,9 +55,21 @@ export function validationOutdatedTags(context) {
let preset = presets.match(entity, graph);
if (!preset) return [];

// Skip all preset upgrades on crossings, see Rapid#1260
// Crossings are special, see Rapid#1260
// This validator can perform preset upgrades on standalone crossing nodes
// that are NOT attached to a parent crossing way.
// If the crossing is: 1. a way or 2. a node attached to a parent crossing way, bail out.
// The `ambiguous_crossing_tags` validator will take care of them.
if (/crossing/.test(preset.id)) return [];
// (i.e. that parent way is the thing that will get validated thoroughly)
if (/crossing/.test(preset.id)) {
if (entity.type === 'way') {
return [];
} else if (entity.type === 'node') {
const parents = graph.parentWays(entity);
const hasParentCrossing = parents.some(parent => _isCrossingWay(parent.tags));
if (hasParentCrossing) return [];
}
}

const oldTags = Object.assign({}, entity.tags); // shallow copy
let subtype = 'deprecated_tags';
Expand Down

0 comments on commit c952ee9

Please sign in to comment.