From 228af9a000de5fa16be1a5df8aec13860a072c02 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Fri, 26 Apr 2019 12:53:05 -0700 Subject: [PATCH] Move areaKeys and setAreaKeys to modules/osm/tags --- modules/core/area_keys.js | 5 ----- modules/core/context.js | 6 +++--- modules/index.js | 2 +- modules/osm/tags.js | 5 +++++ modules/osm/way.js | 5 ++--- modules/presets/preset.js | 6 +++--- modules/services/maprules.js | 2 +- 7 files changed, 15 insertions(+), 16 deletions(-) delete mode 100644 modules/core/area_keys.js diff --git a/modules/core/area_keys.js b/modules/core/area_keys.js deleted file mode 100644 index 945b098e0..000000000 --- a/modules/core/area_keys.js +++ /dev/null @@ -1,5 +0,0 @@ -export var areaKeys = {}; - -export function setAreaKeys(value) { - areaKeys = value; -} diff --git a/modules/core/context.js b/modules/core/context.js index ac683cfc0..9516470ad 100644 --- a/modules/core/context.js +++ b/modules/core/context.js @@ -6,7 +6,7 @@ import { select as d3_select } from 'd3-selection'; import { t, currentLocale, addTranslation, setLocale } from '../util/locale'; -import { setAreaKeys } from './area_keys'; +import { osmSetAreaKeys } from '../osm/tags'; import { coreHistory } from './history'; import { coreValidator } from './validator'; @@ -549,11 +549,11 @@ export function coreContext() { var external = utilStringQs(window.location.hash).presets; presets.fromExternal(external, function(externalPresets) { context.presets = function() { return externalPresets; }; // default + external presets... - setAreaKeys(presets.areaKeys()); + osmSetAreaKeys(presets.areaKeys()); }); } else { presets.init(); - setAreaKeys(presets.areaKeys()); + osmSetAreaKeys(presets.areaKeys()); } return context; diff --git a/modules/index.js b/modules/index.js index ae034647a..efca40c50 100644 --- a/modules/index.js +++ b/modules/index.js @@ -25,7 +25,7 @@ import { services } from './services/index'; var Connection = services.osm; export { Connection }; export { coreContext as Context } from './core/context'; -export { setAreaKeys, areaKeys } from './core/area_keys'; +export { osmSetAreaKeys as setAreaKeys, osmAreaKeys as areaKeys } from './osm/tags'; export { coreDifference as Difference } from './core/difference'; export { coreGraph as Graph } from './core/graph'; export { coreHistory as History } from './core/history'; diff --git a/modules/osm/tags.js b/modules/osm/tags.js index 8103b68bf..10fb9acfd 100644 --- a/modules/osm/tags.js +++ b/modules/osm/tags.js @@ -6,6 +6,11 @@ export function osmIsInterestingTag(key) { key.indexOf('tiger:') !== 0; } +export var osmAreaKeys = {}; + +export function osmSetAreaKeys(value) { + osmAreaKeys = value; +} export var osmOneWayTags = { 'aerialway': { diff --git a/modules/osm/way.js b/modules/osm/way.js index 0b4425df9..d8e70d81a 100644 --- a/modules/osm/way.js +++ b/modules/osm/way.js @@ -3,8 +3,7 @@ import { geoArea as d3_geoArea } from 'd3-geo'; import { geoExtent, geoVecCross } from '../geo'; import { osmEntity } from './entity'; import { osmLanes } from './lanes'; -import { osmOneWayTags, osmRightSideIsInsideTags } from './tags'; -import { areaKeys } from '../core/area_keys'; +import { osmAreaKeys, osmOneWayTags, osmRightSideIsInsideTags } from './tags'; import { utilArrayUniq } from '../util'; @@ -214,7 +213,7 @@ Object.assign(osmWay.prototype, { }; var returnTags = {}; for (var key in this.tags) { - if (key in areaKeys && !(this.tags[key] in areaKeys[key])) { + if (key in osmAreaKeys && !(this.tags[key] in osmAreaKeys[key])) { returnTags[key] = this.tags[key]; return returnTags; } diff --git a/modules/presets/preset.js b/modules/presets/preset.js index 1416a6a2a..1e2515869 100644 --- a/modules/presets/preset.js +++ b/modules/presets/preset.js @@ -1,5 +1,5 @@ import { t } from '../util/locale'; -import { areaKeys } from '../core/area_keys'; +import { osmAreaKeys } from '../osm/tags'; import { utilArrayUniq, utilObjectOmit } from '../util'; @@ -235,14 +235,14 @@ export function presetPreset(id, preset, fields, visible, rawPresets) { // Add area=yes if necessary. // This is necessary if the geometry is already an area (e.g. user drew an area) AND any of: // 1. chosen preset could be either an area or a line (`barrier=city_wall`) - // 2. chosen preset doesn't have a key in areaKeys (`railway=station`) + // 2. chosen preset doesn't have a key in osmAreaKeys (`railway=station`) if (!addTags.hasOwnProperty('area')) { delete tags.area; if (geometry === 'area') { var needsAreaTag = true; if (preset.geometry.indexOf('line') === -1) { for (k in addTags) { - if (k in areaKeys) { + if (k in osmAreaKeys) { needsAreaTag = false; break; } diff --git a/modules/services/maprules.js b/modules/services/maprules.js index 559969872..4a1950228 100644 --- a/modules/services/maprules.js +++ b/modules/services/maprules.js @@ -1,4 +1,4 @@ -import { areaKeys } from '../core/area_keys'; +import { osmAreaKeys as areaKeys } from '../osm/tags'; import { utilArrayIntersection } from '../util'; import { validationIssue } from '../core/validation';