diff --git a/dist/locales/en.json b/dist/locales/en.json index 660ef793a..ea503fedb 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -1,9 +1,13 @@ { "en": { "icons": { + "download": "download", "information": "info", "remove": "remove", - "undo": "undo" + "undo": "undo", + "zoom_to": "zoom to", + "copy": "copy", + "open_wikidata": "open on wikidata.org" }, "modes": { "add_area": { @@ -7682,41 +7686,6 @@ "description": "Orthophotos from the municipality of Helsingborg 2016, public domain", "name": "Helsingborg Orthophoto" }, - "eufar-balaton": { - "attribution": { - "text": "EUFAR Balaton ortofotó 2010" - }, - "description": "1940 geo-tagged photography from Balaton Limnological Institute.", - "name": "EUFAR Balaton orthophotos" - }, - "finds.jp_KBN_2500": { - "attribution": { - "text": "GSI KIBAN 2500" - }, - "description": "GSI Kiban 2500 via finds.jp. Good for tracing, but a bit older.", - "name": "Japan GSI KIBAN 2500" - }, - "gsi.go.jp": { - "attribution": { - "text": "GSI Japan" - }, - "description": "Japan GSI ortho Imagery. Usually better than bing, but a bit older.", - "name": "Japan GSI ortho Imagery" - }, - "gsi.go.jp_std_map": { - "attribution": { - "text": "GSI Japan" - }, - "description": "Japan GSI Standard Map. Widely covered.", - "name": "Japan GSI Standard Map" - }, - "helsingborg-orto": { - "attribution": { - "text": "© Helsingborg municipality" - }, - "description": "Orthophotos from the municipality of Helsingborg 2016, public domain", - "name": "Helsingborg Orthophoto" - }, "kalmar-orto-2014": { "attribution": { "text": "© Kalmar municipality" @@ -7844,13 +7813,6 @@ "description": "Orthophotos from the municipality of Stockholm 2015, CC0 license", "name": "Stockholm Orthophoto" }, - "stockholm-orto": { - "attribution": { - "text": "© Stockholm municipality, CC0" - }, - "description": "Orthophotos from the municipality of Stockholm 2015, CC0 license", - "name": "Stockholm Orthophoto" - }, "tf-cycle": { "attribution": { "text": "Maps © Thunderforest, Data © OpenStreetMap contributors" diff --git a/modules/core/context.js b/modules/core/context.js index c99d4eb08..53385070d 100644 --- a/modules/core/context.js +++ b/modules/core/context.js @@ -470,14 +470,14 @@ export function coreContext() { background = rendererBackground(context); features = rendererFeatures(context); presets = presetIndex(); - - if (utilStringQs(window.location.hash).validations) { + + if (services.maprules && utilStringQs(window.location.hash).validations) { var validations = utilStringQs(window.location.hash).validations; d3_json(validations, function (err, mapcss) { if (err) return; services.maprules.init(context.presets().areaKeys()); _each(mapcss, function(mapcssSelector) { - return services.maprules.addRule(mapcssSelector); + return services.maprules.addRule(mapcssSelector); }); context.validationRules = true; }); diff --git a/modules/presets/index.js b/modules/presets/index.js index bade492ed..ddeeb3ba9 100644 --- a/modules/presets/index.js +++ b/modules/presets/index.js @@ -173,7 +173,7 @@ export function presetIndex() { var geometry = preset.geometry; for (var j = 0; j < geometry.length; j++) { - var g = _index[geometry[j]]; + var g = _index[geometry[j]]; for (var k in preset.tags) { (g[k] = g[k] || []).push(preset); } @@ -183,7 +183,7 @@ export function presetIndex() { }; all.init = function() { - all.collection = []; + all.collection = []; _recent.collection = []; _fields = {}; _universal = []; @@ -192,7 +192,7 @@ export function presetIndex() { return all.build(data.presets, true); }; - + all.reset = function() { all.collection = []; _defaults = { area: all, line: all, point: all, vertex: all, relation: all }; diff --git a/modules/services/maprules.js b/modules/services/maprules.js index 5944d8ae1..9e2f44a4f 100644 --- a/modules/services/maprules.js +++ b/modules/services/maprules.js @@ -16,7 +16,7 @@ var buildRuleChecks = function() { }; }, absence: function(absence) { - return function(tags) { + return function(tags) { return Object.keys(tags).indexOf(absence) === -1; }; }, @@ -44,7 +44,7 @@ var buildRuleChecks = function() { lessThan: function(lessThan) { var key = Object.keys(lessThan)[0]; var value = lessThan[key]; - + return function(tags) { return tags[key] < value; }; @@ -52,9 +52,9 @@ var buildRuleChecks = function() { lessThanEqual: function(lessThanEqual) { var key = Object.keys(lessThanEqual)[0]; var value = lessThanEqual[key]; - + return function(tags) { - return tags[key] <= value; + return tags[key] <= value; }; }, positiveRegex: function(positiveRegex) { @@ -70,7 +70,7 @@ var buildRuleChecks = function() { var tagKey = Object.keys(negativeRegex)[0]; var expression = negativeRegex[tagKey].join('|'); var regex = new RegExp(expression); - + return function(tags) { return !regex.test(tags[tagKey]); }; @@ -128,23 +128,23 @@ export default { if (isRegex || isEqual) { Object.keys(selector[key]).forEach(function(selectorKey) { values = isEqual ? [selector[key][selectorKey]] : getRegexValues(selector[key][selectorKey]); - + if (expectedTags.hasOwnProperty(selectorKey)) { values = values.concat(expectedTags[selectorKey]); } - + expectedTags[selectorKey] = values; }); - + } else if (/(greater|less)Than(Equal)?|presence/g.test(key)) { var tagKey = /presence/.test(key) ? selector[key] : Object.keys(selector[key])[0]; - + values = [selector[key][tagKey]]; if (expectedTags.hasOwnProperty(tagKey)) { values = values.concat(expectedTags[tagKey]); } - + expectedTags[tagKey] = values; } @@ -173,7 +173,7 @@ export default { return 'line'; } } - + for (var key in tagMap) { if (key in _areaKeys && !isAreaKeyBlackList(key)) { return 'area'; @@ -192,15 +192,15 @@ export default { checks: this.filterRuleChecks(selector), // true if all conditions for a tag error are true.. matches: function(entity) { - return _every(this.checks, function(check) { - return check(entity.tags); + return _every(this.checks, function(check) { + return check(entity.tags); }); }, // borrowed from Way#isArea() - inferredGeometry: this.inferGeometry(this.buildTagMap(selector), this._areaKeys), + inferredGeometry: this.inferGeometry(this.buildTagMap(selector), this._areaKeys), geometryMatches: function(entity, graph) { - if (entity.type === 'node' || entity.type === 'relation') { - return selector.geometry === entity.type; + if (entity.type === 'node' || entity.type === 'relation') { + return selector.geometry === entity.type; } else if (entity.type === 'way') { return this.inferredGeometry === entity.geometry(graph); } diff --git a/modules/validations/mapcss_checks.js b/modules/validations/mapcss_checks.js index 86255a917..13fa6fe2b 100644 --- a/modules/validations/mapcss_checks.js +++ b/modules/validations/mapcss_checks.js @@ -1,8 +1,10 @@ -import { serviceMapRules } from '../services'; +import { services } from '../services'; export function validationMapCSSChecks() { var validation = function(changes, graph) { - var rules = serviceMapRules.validationRules(); + if (!services.maprules) return []; + + var rules = services.maprules.validationRules(); var warnings = []; var createdModified = ['created', 'modified']; diff --git a/test/index.html b/test/index.html index 04ebd669f..b455624b3 100644 --- a/test/index.html +++ b/test/index.html @@ -106,14 +106,13 @@ + - - diff --git a/test/spec/services/maprules.js b/test/spec/services/maprules.js index cf17f7266..188588d0e 100644 --- a/test/spec/services/maprules.js +++ b/test/spec/services/maprules.js @@ -1,11 +1,17 @@ describe('maprules', function() { - var _ruleChecks, validationRules; + var _ruleChecks, validationRules; + before(function() { + iD.services.maprules = iD.serviceMapRules; var areaKeys = iD.Context().presets().areaKeys(); iD.serviceMapRules.init(areaKeys); _ruleChecks = iD.serviceMapRules.ruleChecks(); }); + after(function() { + delete iD.services.maprules; + }); + describe('#filterRuleChecks', function() { it('returns shortlist of mapcss checks relevant to provided selector', function() { var selector = { @@ -30,9 +36,9 @@ describe('maprules', function() { [ { t: { - equals: { - man_made: 'tower', - 'tower:type': 'communication' + equals: { + man_made: 'tower', + 'tower:type': 'communication' } }, r: { @@ -42,9 +48,9 @@ describe('maprules', function() { }, { t: { - equals: { - building: 'yes', - amenity: 'school' + equals: { + building: 'yes', + amenity: 'school' }, positiveRegex: { opening_hours: [ @@ -96,7 +102,7 @@ describe('maprules', function() { positiveRegex: { amenity: ['^school$', '^healthcare$'] }, error: 'amenity cannot be healthcare or school!' }; - + var areaDerivedArea = { geometry: 'closedway', equals: { area: 'yes' }, @@ -141,7 +147,7 @@ describe('maprules', function() { describe('#addRule', function() { it ('builds a rule from provided selector and adds it to _validationRules', function () { - var selector = { + var selector = { geometry:'node', equals: {amenity:'marketplace'}, absence:'name', @@ -303,7 +309,7 @@ describe('maprules', function() { var selectors; before(function() { selectors = [ - { + { geometry:'node', equals: {amenity:'marketplace'}, absence:'name', @@ -361,12 +367,12 @@ describe('maprules', function() { iD.serviceMapRules.clearRules(); selectors.forEach(function(selector) { iD.serviceMapRules.addRule(selector); }); validationRules = iD.serviceMapRules.validationRules(); - }); + }); describe('#matches', function() { var selectors, entities; before(function() { selectors = [ - { + { geometry:'node', equals: {amenity:'marketplace'}, absence:'name', @@ -435,7 +441,7 @@ describe('maprules', function() { iD.serviceMapRules.clearRules(); selectors.forEach(function(selector) { iD.serviceMapRules.addRule(selector); }); validationRules = iD.serviceMapRules.validationRules(); - }); + }); it('is true when each rule check is \'true\'', function() { validationRules.forEach(function(rule, i) { expect(rule.matches(entities[i])).to.be.true; @@ -461,7 +467,7 @@ describe('maprules', function() { before(function() { selectors = [ - { + { geometry:'node', equals: {amenity:'marketplace'}, absence:'name', @@ -545,12 +551,12 @@ describe('maprules', function() { var warnings = []; var entity = entities[i]; var selector = selectors[i]; - + rule.findWarnings(entity, _graph, warnings); - + var warning = warnings[0]; var type = Object.keys(selector).indexOf('error') ? 'error' : 'warning'; - + expect(warnings.length).to.eql(1); expect(warning.entity).to.eql(entity); expect(warning.message).to.eql(selector[type]);