refactor isOneWay to properly support bidirectional ways (#10730)

This commit is contained in:
Kyℓe Hensel
2025-02-13 00:22:09 +11:00
committed by GitHub
parent 4e1c16efc7
commit 4747ae253c
12 changed files with 117 additions and 65 deletions
+23
View File
@@ -7,3 +7,26 @@ export function utilObjectOmit(obj, omitKeys) {
return result;
}, {});
}
/**
* @template T
* @typedef {{ [key: string]: { [value: string]: T } }} TagDictionary<T>
*/
/**
* searches a dictionary for a match, such as `osmOneWayForwardTags`,
* `osmAreaKeysExceptions`, etc.
* @template T
* @param {Tags} tags
* @param {TagDictionary<T>} tagDictionary
* @returns {T | undefined}
*/
export function utilCheckTagDictionary(tags, tagDictionary) {
for (const key in tags) {
const value = tags[key];
if (tagDictionary[key] && value in tagDictionary[key]) {
return tagDictionary[key][value];
}
}
return undefined;
}