MCPcopy Create free account
hub / github.com/facebook/Rapid / areaKeys

Method areaKeys

modules/core/PresetSystem.js:392–424  ·  view source on GitHub ↗

* areaKeys * Because of the open nature of tagging, we will never have a complete * list of tags used in OSM, so we want it to have logic like "assume * that a closed way with an amenity tag is an area, unless the amenity * is one of these specific types". This function computes a struct

()

Source from the content-addressed store, hash-verified

390 * @returns areaKeys Object
391 */
392 areaKeys() {
393 // The ignore list is for keys that imply lines. (We always add `area=yes` for exceptions)
394 const ignore = ['barrier', 'highway', 'footway', 'railway', 'junction', 'type'];
395 let areaKeys = {};
396
397 // ignore name-suggestion-index and deprecated presets
398 const presets = Object.values(this._presets).filter(p => !p.suggestion && !p.replacement);
399
400 // keeplist
401 for (const p of presets) {
402 const k = Object.keys(p.tags)[0]; // pick the first tag
403 if (!k) continue;
404 if (ignore.includes(k)) continue;
405
406 if (p.geometry.includes('area')) { // probably an area..
407 areaKeys[k] = areaKeys[k] || {};
408 }
409 }
410
411 // discardlist
412 for (const p of presets) {
413 if (!p.geometry.includes('line')) continue;
414 for (const [k, v] of Object.entries(p.addTags)) {
415 // examine all addTags to get a better sense of what can be tagged on lines - iD#6800
416 // probably an area... but sometimes a line.
417 if (k in areaKeys && v !== '*') {
418 areaKeys[k][v] = true;
419 }
420 }
421 }
422
423 return areaKeys;
424 }
425
426
427 pointTags() {

Callers 2

initAsyncMethod · 0.95

Calls 3

filterMethod · 0.80
valuesMethod · 0.80
keysMethod · 0.45

Tested by

no test coverage detected