Improve code for keeping only interesting key/value pairs

Before it was not actually checking that the osmvalue was in the vmap,
so we were testing a bunch of pairs like `highway/crossing` and
`highway/residential` that would never match a NSI category.
This commit is contained in:
Bryan Housel
2021-08-05 16:59:07 -04:00
parent c8aedcbb79
commit 15ee63e875

View File

@@ -163,7 +163,7 @@ function loadNsiData() {
// and fallbacks like
// "amenity/yes"
// excluding things like
// "highway", "surface", "ref", etc.
// "tiger:reviewed", "surface", "ref", etc.
//
// Arguments
// `tags`: `Object` containing the feature's OSM tags
@@ -183,12 +183,12 @@ function gatherKVs(tags) {
if (!osmvalue) return;
const vmap = _nsi.kvt.get(osmkey);
if (!vmap) return;
if (!vmap) return; // not an interesting key
if (osmvalue !== 'yes') {
primary.add(`${osmkey}/${osmvalue}`);
} else {
alternate.add(`${osmkey}/${osmvalue}`);
if (vmap.get(osmvalue)) { // Matched a category in NSI
primary.add(`${osmkey}/${osmvalue}`); // interesting key/value
} else if (osmvalue === 'yes') {
alternate.add(`${osmkey}/${osmvalue}`); // fallback key/yes
}
});