diff --git a/data/presets.yaml b/data/presets.yaml index b22c9cf1d..2d9254d76 100644 --- a/data/presets.yaml +++ b/data/presets.yaml @@ -6726,6 +6726,11 @@ en: name: Windmill # 'terms: wind,wheel,mill' terms: '' + man_made/windpump: + # man_made=windpump + name: Windpump + # 'terms: aerorotor,water pump,windmill,wind pump' + terms: '' man_made/works: # man_made=works name: Factory diff --git a/data/presets/presets.json b/data/presets/presets.json index f6d770932..7a0bd479b 100644 --- a/data/presets/presets.json +++ b/data/presets/presets.json @@ -821,6 +821,7 @@ "man_made/water_works": {"icon": "temaki-powered_pump", "fields": ["name", "operator", "address"], "moreFields": ["gnis/feature_id"], "geometry": ["point", "area"], "tags": {"man_made": "water_works"}, "name": "Water Works"}, "man_made/watermill": {"icon": "maki-watermill", "fields": ["building_area"], "moreFields": ["gnis/feature_id"], "geometry": ["point", "area"], "terms": ["water", "wheel", "mill"], "tags": {"man_made": "watermill"}, "name": "Watermill"}, "man_made/windmill": {"icon": "maki-windmill", "fields": ["building_area"], "moreFields": ["gnis/feature_id"], "geometry": ["point", "area"], "terms": ["wind", "wheel", "mill"], "tags": {"man_made": "windmill"}, "name": "Windmill"}, + "man_made/windpump": {"icon": "temaki-windpump", "fields": ["ref", "operator", "height", "material", "manufacturer", "lit"], "geometry": ["point"], "terms": ["aerorotor", "water pump", "windmill", "wind pump"], "tags": {"man_made": "windpump"}, "name": "Windpump"}, "man_made/works": {"icon": "maki-industry", "fields": ["name", "operator", "address", "building_area", "product"], "moreFields": ["email", "fax", "gnis/feature_id", "phone", "website"], "geometry": ["point", "area"], "terms": ["assembly", "build", "brewery", "car", "plant", "plastic", "processing", "manufacture", "refinery"], "tags": {"man_made": "works"}, "name": "Factory"}, "marker": {"icon": "temaki-silo", "fields": ["ref", "operator", "marker", "utility", "inscription", "colour"], "moreFields": ["height", "location", "manufacturer", "material"], "geometry": ["point"], "terms": ["identifier", "marking", "plate", "pole", "post", "sign"], "tags": {"marker": "*"}, "name": "Marker"}, "marker/utility": {"icon": "temaki-silo", "fields": ["ref", "operator", "marker", "utility", "{marker}"], "geometry": ["point"], "terms": ["gas line marker", "identifier", "marking", "oil marker", "pipline marker", "plate", "pole", "post", "sign"], "tags": {"marker": "*", "utility": "*"}, "name": "Utility Marker"}, diff --git a/data/presets/presets/man_made/windpump.json b/data/presets/presets/man_made/windpump.json new file mode 100644 index 000000000..dd32b4acc --- /dev/null +++ b/data/presets/presets/man_made/windpump.json @@ -0,0 +1,24 @@ +{ + "icon": "temaki-windpump", + "fields": [ + "ref", + "operator", + "height", + "material", + "manufacturer", + "lit" + ], + "geometry": [ + "point" + ], + "terms": [ + "aerorotor", + "water pump", + "windmill", + "wind pump" + ], + "tags": { + "man_made": "windpump" + }, + "name": "Windpump" +} diff --git a/data/taginfo.json b/data/taginfo.json index e8270da77..dd08e8d0b 100644 --- a/data/taginfo.json +++ b/data/taginfo.json @@ -799,6 +799,7 @@ {"key": "man_made", "value": "water_works", "description": "🄿 Water Works", "object_types": ["node", "area"], "icon_url": "https://cdn.jsdelivr.net/gh/ideditor/temaki/icons/powered_pump.svg"}, {"key": "man_made", "value": "watermill", "description": "🄿 Watermill", "object_types": ["node", "area"], "icon_url": "https://cdn.jsdelivr.net/gh/mapbox/maki/icons/watermill-15.svg"}, {"key": "man_made", "value": "windmill", "description": "🄿 Windmill", "object_types": ["node", "area"], "icon_url": "https://cdn.jsdelivr.net/gh/mapbox/maki/icons/windmill-15.svg"}, + {"key": "man_made", "value": "windpump", "description": "🄿 Windpump", "object_types": ["node"], "icon_url": "https://cdn.jsdelivr.net/gh/ideditor/temaki/icons/windpump.svg"}, {"key": "man_made", "value": "works", "description": "🄿 Factory", "object_types": ["node", "area"], "icon_url": "https://cdn.jsdelivr.net/gh/mapbox/maki/icons/industry-15.svg"}, {"key": "marker", "description": "🄿 Marker, 🄵 Type", "object_types": ["node"], "icon_url": "https://cdn.jsdelivr.net/gh/ideditor/temaki/icons/silo.svg"}, {"key": "utility", "description": "🄿 Utility Marker, 🄵 Utilities, 🄵 Utility", "object_types": ["node"], "icon_url": "https://cdn.jsdelivr.net/gh/ideditor/temaki/icons/silo.svg"}, diff --git a/dist/locales/en.json b/dist/locales/en.json index 8777c78e6..9292bf4ef 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -8632,6 +8632,10 @@ "name": "Windmill", "terms": "wind,wheel,mill" }, + "man_made/windpump": { + "name": "Windpump", + "terms": "aerorotor,water pump,windmill,wind pump" + }, "man_made/works": { "name": "Factory", "terms": "assembly,build,brewery,car,plant,plastic,processing,manufacture,refinery" diff --git a/modules/presets/collection.js b/modules/presets/collection.js index dd1b56021..c2f419cb1 100644 --- a/modules/presets/collection.js +++ b/modules/presets/collection.js @@ -1,4 +1,5 @@ -import { utilArrayUniq, utilEditDistance } from '../util'; +import { utilArrayIntersection, utilArrayUniq } from '../util/array'; +import { utilEditDistance } from '../util'; // @@ -45,7 +46,7 @@ export function presetCollection(collection) { return _this.item(id); }; - _this.search = (value, geometry, countryCode) => { + _this.search = (value, geometry, countryCodes) => { if (!value) return _this; value = value.toLowerCase().trim(); @@ -83,10 +84,13 @@ export function presetCollection(collection) { } let pool = _this.collection; - if (countryCode) { + if (countryCodes) { + if (typeof countryCodes === 'string') countryCodes = [countryCodes]; + countryCodes = countryCodes.map(code => code.toLowerCase()); + pool = pool.filter(a => { - if (a.countryCodes && a.countryCodes.indexOf(countryCode) === -1) return false; - if (a.notCountryCodes && a.notCountryCodes.indexOf(countryCode) !== -1) return false; + if (a.countryCodes && !utilArrayIntersection(a.countryCodes, countryCodes).length) return false; + if (a.notCountryCodes && utilArrayIntersection(a.notCountryCodes, countryCodes).length) return false; return true; }); } diff --git a/modules/ui/field.js b/modules/ui/field.js index d26343bf1..bd92c1afd 100644 --- a/modules/ui/field.js +++ b/modules/ui/field.js @@ -9,6 +9,7 @@ import { geoExtent } from '../geo/extent'; import { uiFieldHelp } from './field_help'; import { uiFields } from './fields'; import { uiTagReference } from './tag_reference'; +import { utilArrayIntersection } from '../util/array'; import { utilRebind, utilUniqueDomId } from '../util'; @@ -306,16 +307,14 @@ export function uiField(context, presetField, entityIDs, options) { if (!extent) return true; var center = extent.center(); - var countryCode = countryCoder.iso1A2Code(center); + var codes = countryCoder.iso1A2Codes(center).map(function(code) { + return code.toLowerCase(); + }); - if (!countryCode) return false; - - countryCode = countryCode.toLowerCase(); - - if (field.countryCodes && field.countryCodes.indexOf(countryCode) === -1) { + if (field.countryCodes && !utilArrayIntersection(codes, field.countryCodes).length) { return false; } - if (field.notCountryCodes && field.notCountryCodes.indexOf(countryCode) !== -1) { + if (field.notCountryCodes && utilArrayIntersection(codes, field.notCountryCodes).length) { return false; } } diff --git a/modules/ui/preset_list.js b/modules/ui/preset_list.js index 3402918ff..aa92d508e 100644 --- a/modules/ui/preset_list.js +++ b/modules/ui/preset_list.js @@ -98,9 +98,9 @@ export function uiPresetList(context) { var results, messageText; if (value.length && extent) { var center = extent.center(); - var countryCode = countryCoder.iso1A2Code(center); + var countryCodes = countryCoder.iso1A2Codes(center); - results = presets.search(value, entityGeometries()[0], countryCode && countryCode.toLowerCase()); + results = presets.search(value, entityGeometries()[0], countryCodes); messageText = t('inspector.results', { n: results.collection.length, search: value diff --git a/package.json b/package.json index c8bd2fefe..c93355e4a 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "translations": "node scripts/update_locales.js" }, "dependencies": { - "@ideditor/country-coder": "^3.2.0", + "@ideditor/country-coder": "^4.0.0", "@ideditor/location-conflation": "~0.5.0", "@mapbox/sexagesimal": "1.2.0", "@mapbox/togeojson": "0.16.0", @@ -106,7 +106,7 @@ "phantomjs-prebuilt": "~2.1.11", "postcss": "^8.1.1", "postcss-selector-prepend": "^0.5.0", - "rollup": "~2.31.0", + "rollup": "~2.32.0", "rollup-plugin-includepaths": "~0.2.3", "rollup-plugin-progress": "^1.1.1", "rollup-plugin-visualizer": "~4.1.1",