Move areaKeys and setAreaKeys to modules/osm/tags

This commit is contained in:
Quincy Morgan
2019-04-26 12:53:05 -07:00
parent ecc217f5d8
commit 228af9a000
7 changed files with 15 additions and 16 deletions

View File

@@ -1,5 +0,0 @@
export var areaKeys = {};
export function setAreaKeys(value) {
areaKeys = value;
}

View File

@@ -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;

View File

@@ -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';

View File

@@ -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': {

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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';