add fallback values for access field for barriers

This commit is contained in:
Martin Raifer
2022-06-20 19:03:50 +02:00
parent 69edff39f0
commit 5ce8eb139c
2 changed files with 166 additions and 113 deletions
+1
View File
@@ -56,6 +56,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
* Disable taginfo suggestions for the `via` field ([#9140], thanks [@k-yle])
* Treat `surface=chipseal` as a paved surface ([#9139], thanks [@k-yle])
* Better fallback icons for untagged points, vertices, lines and areas ([#9157])
* Add fallback values for access field for barrier presets
#### :hammer: Development
+165 -113
View File
@@ -107,109 +107,154 @@ export function uiFieldAccess(field, context) {
};
var placeholdersByHighway = {
footway: {
foot: 'designated',
motor_vehicle: 'no'
const placeholdersByTag = {
highway: {
footway: {
foot: 'designated',
motor_vehicle: 'no'
},
steps: {
foot: 'yes',
motor_vehicle: 'no',
bicycle: 'no',
horse: 'no'
},
pedestrian: {
foot: 'yes',
motor_vehicle: 'no'
},
cycleway: {
motor_vehicle: 'no',
bicycle: 'designated'
},
bridleway: {
motor_vehicle: 'no',
horse: 'designated'
},
path: {
foot: 'yes',
motor_vehicle: 'no',
bicycle: 'yes',
horse: 'yes'
},
motorway: {
foot: 'no',
motor_vehicle: 'yes',
bicycle: 'no',
horse: 'no'
},
trunk: {
motor_vehicle: 'yes'
},
primary: {
foot: 'yes',
motor_vehicle: 'yes',
bicycle: 'yes',
horse: 'yes'
},
secondary: {
foot: 'yes',
motor_vehicle: 'yes',
bicycle: 'yes',
horse: 'yes'
},
tertiary: {
foot: 'yes',
motor_vehicle: 'yes',
bicycle: 'yes',
horse: 'yes'
},
residential: {
foot: 'yes',
motor_vehicle: 'yes',
bicycle: 'yes',
horse: 'yes'
},
unclassified: {
foot: 'yes',
motor_vehicle: 'yes',
bicycle: 'yes',
horse: 'yes'
},
service: {
foot: 'yes',
motor_vehicle: 'yes',
bicycle: 'yes',
horse: 'yes'
},
motorway_link: {
foot: 'no',
motor_vehicle: 'yes',
bicycle: 'no',
horse: 'no'
},
trunk_link: {
motor_vehicle: 'yes'
},
primary_link: {
foot: 'yes',
motor_vehicle: 'yes',
bicycle: 'yes',
horse: 'yes'
},
secondary_link: {
foot: 'yes',
motor_vehicle: 'yes',
bicycle: 'yes',
horse: 'yes'
},
tertiary_link: {
foot: 'yes',
motor_vehicle: 'yes',
bicycle: 'yes',
horse: 'yes'
},
construction: {
access: 'no'
}
},
steps: {
foot: 'yes',
motor_vehicle: 'no',
bicycle: 'no',
horse: 'no'
},
pedestrian: {
foot: 'yes',
motor_vehicle: 'no'
},
cycleway: {
motor_vehicle: 'no',
bicycle: 'designated'
},
bridleway: {
motor_vehicle: 'no',
horse: 'designated'
},
path: {
foot: 'yes',
motor_vehicle: 'no',
bicycle: 'yes',
horse: 'yes'
},
motorway: {
foot: 'no',
motor_vehicle: 'yes',
bicycle: 'no',
horse: 'no'
},
trunk: {
motor_vehicle: 'yes'
},
primary: {
foot: 'yes',
motor_vehicle: 'yes',
bicycle: 'yes',
horse: 'yes'
},
secondary: {
foot: 'yes',
motor_vehicle: 'yes',
bicycle: 'yes',
horse: 'yes'
},
tertiary: {
foot: 'yes',
motor_vehicle: 'yes',
bicycle: 'yes',
horse: 'yes'
},
residential: {
foot: 'yes',
motor_vehicle: 'yes',
bicycle: 'yes',
horse: 'yes'
},
unclassified: {
foot: 'yes',
motor_vehicle: 'yes',
bicycle: 'yes',
horse: 'yes'
},
service: {
foot: 'yes',
motor_vehicle: 'yes',
bicycle: 'yes',
horse: 'yes'
},
motorway_link: {
foot: 'no',
motor_vehicle: 'yes',
bicycle: 'no',
horse: 'no'
},
trunk_link: {
motor_vehicle: 'yes'
},
primary_link: {
foot: 'yes',
motor_vehicle: 'yes',
bicycle: 'yes',
horse: 'yes'
},
secondary_link: {
foot: 'yes',
motor_vehicle: 'yes',
bicycle: 'yes',
horse: 'yes'
},
tertiary_link: {
foot: 'yes',
motor_vehicle: 'yes',
bicycle: 'yes',
horse: 'yes'
},
construction: {
access: 'no'
barrier: {
bollard: {
access: 'no',
bicycle: 'yes',
foot: 'yes'
},
bus_trap: {
motor_vehicle: 'no',
psv: 'yes',
foot: 'yes',
bicycle: 'yes'
},
city_wall: {
access: 'no'
},
coupure: {
access: 'yes'
},
cycle_barrier: {
motor_vehicle: 'no'
},
ditch: {
access: 'no'
},
entrance: {
access: 'yes'
},
fence: {
access: 'no'
},
hedge: {
access: 'no'
},
jersey_barrier: {
access: 'no'
},
motorcycle_barrier: {
motor_vehicle: 'no'
},
rail_guard: {
access: 'no'
}
}
};
@@ -238,26 +283,33 @@ export function uiFieldAccess(field, context) {
if (tags.access && typeof tags.access === 'string') {
return tags.access;
}
if (tags.highway) {
if (typeof tags.highway === 'string') {
if (placeholdersByHighway[tags.highway] &&
placeholdersByHighway[tags.highway][d]) {
return placeholdersByHighway[tags.highway][d];
function getPlaceholdersByTag(key, placeholdersByKey) {
if (typeof tags[key] === 'string') {
if (placeholdersByKey[tags[key]] &&
placeholdersByKey[tags[key]][d]) {
return placeholdersByKey[tags[key]][d];
}
} else {
var impliedAccesses = tags.highway.filter(Boolean).map(function(highwayVal) {
return placeholdersByHighway[highwayVal] && placeholdersByHighway[highwayVal][d];
var impliedAccesses = tags[key].filter(Boolean).map(function(val) {
return placeholdersByKey[val] && placeholdersByKey[val][d];
}).filter(Boolean);
if (impliedAccesses.length === tags.highway.length &&
if (impliedAccesses.length === tags[key].length &&
new Set(impliedAccesses).size === 1) {
// if all the highway values have the same implied access for this type then use that
// if all the barrier values have the same implied access for this type then use that
return impliedAccesses[0];
}
}
}
if (d === 'access') {
for (const key in placeholdersByTag) {
if (tags[key]) {
const impliedAccess = getPlaceholdersByTag(key, placeholdersByTag[key]);
if (impliedAccess) {
return impliedAccess;
}
}
}
if (d === 'access' && !tags.barrier) {
return 'yes';
}
return field.placeholder();