Generalize wikidata field type

Add Species Wikidata field to tree, orchard, and animal enclosure presets (close #6652)
This commit is contained in:
Quincy Morgan
2019-07-31 16:59:44 -04:00
parent 68439498c9
commit 3ca01d3690
10 changed files with 66 additions and 36 deletions
+3
View File
@@ -1921,6 +1921,9 @@ en:
source:
# source=*
label: Sources
species/wikidata:
# 'species:wikidata=*, species:wikipedia=*'
label: Species Wikidata
sport:
# sport=*
label: Sports
+1
View File
@@ -344,6 +344,7 @@
"social_facility_for": {"key": "social_facility:for", "type": "combo", "label": "People Served"},
"social_facility": {"key": "social_facility", "type": "combo", "label": "Type"},
"source": {"key": "source", "type": "semiCombo", "icon": "source", "universal": true, "label": "Sources", "snake_case": false, "caseSensitive": true, "options": ["survey", "local knowledge", "gps", "aerial imagery", "streetlevel imagery"]},
"species/wikidata": {"key": "species:wikidata", "keys": ["species:wikidata", "species:wikipedia"], "type": "wikidata", "label": "Species Wikidata"},
"sport_ice": {"key": "sport", "type": "semiCombo", "label": "Sports", "options": ["ice_skating", "ice_hockey", "multi", "curling", "ice_stock"]},
"sport_racing_motor": {"key": "sport", "type": "semiCombo", "label": "Sports", "options": ["motor", "karting", "motocross"]},
"sport_racing_nonmotor": {"key": "sport", "type": "semiCombo", "label": "Sports", "options": ["bmx", "cycling", "dog_racing", "horse_racing", "running"]},
@@ -0,0 +1,9 @@
{
"key": "species:wikidata",
"keys": [
"species:wikidata",
"species:wikipedia"
],
"type": "wikidata",
"label": "Species Wikidata"
}
+3 -3
View File
@@ -255,7 +255,7 @@
"area": {"fields": ["name"], "geometry": ["area"], "tags": {"area": "yes"}, "terms": ["polygon"], "name": "Area", "matchScore": 0.1},
"area/highway": {"fields": ["name", "area/highway", "surface"], "geometry": ["area"], "terms": ["area:highway", "edge of pavement", "highway area", "highway shape", "pavement", "road shape", "street area"], "tags": {"area:highway": "*"}, "name": "Road Surface"},
"attraction/amusement_ride": {"icon": "maki-amusement-park", "geometry": ["point", "area"], "terms": ["theme park", "carnival ride"], "tags": {"attraction": "amusement_ride"}, "name": "Amusement Ride"},
"attraction/animal": {"icon": "maki-zoo", "fields": ["name", "operator"], "geometry": ["point", "area"], "terms": ["amphibian", "animal park", "aquarium", "bear", "bird", "fish", "insect", "lion", "mammal", "monkey", "penguin", "reptile", "safari", "theme park", "tiger", "zoo"], "tags": {"attraction": "animal"}, "name": "Animal Enclosure"},
"attraction/animal": {"icon": "maki-zoo", "fields": ["name", "operator", "species/wikidata"], "geometry": ["point", "area"], "terms": ["amphibian", "animal park", "aquarium", "bear", "bird", "fish", "insect", "lion", "mammal", "monkey", "penguin", "reptile", "safari", "theme park", "tiger", "zoo"], "tags": {"attraction": "animal"}, "name": "Animal Enclosure"},
"attraction/big_wheel": {"icon": "maki-amusement-park", "fields": ["{attraction}", "height"], "geometry": ["point"], "terms": ["ferris wheel", "theme park", "amusement ride"], "tags": {"attraction": "big_wheel"}, "name": "Big Wheel"},
"attraction/bumper_car": {"icon": "maki-car", "geometry": ["point", "area"], "terms": ["theme park", "dodgem cars", "autoscooter"], "tags": {"attraction": "bumper_car"}, "name": "Bumper Car"},
"attraction/bungee_jumping": {"icon": "maki-pitch", "fields": ["{attraction}", "height"], "geometry": ["point", "area"], "terms": ["theme park", "bungy jumping", "jumping platform"], "tags": {"attraction": "bungee_jumping"}, "name": "Bungee Jumping"},
@@ -590,7 +590,7 @@
"landuse/military/obstacle_course": {"icon": "temaki-military", "geometry": ["point", "area"], "tags": {"military": "obstacle_course"}, "addTags": {"landuse": "military", "military": "obstacle_course"}, "terms": ["army", "base", "force", "guard", "marine", "navy", "troop", "war"], "name": "Obstacle Course"},
"landuse/military/range": {"icon": "temaki-military", "fields": ["name"], "geometry": ["point", "area"], "tags": {"military": "range"}, "addTags": {"landuse": "military", "military": "range"}, "terms": ["air force", "army", "base", "fight", "fire", "force", "guard", "gun", "marine", "navy", "rifle", "shoot*", "snip*", "train", "troop", "war"], "name": "Military Range"},
"landuse/military/training_area": {"icon": "temaki-military", "fields": ["name"], "geometry": ["point", "area"], "tags": {"military": "training_area"}, "addTags": {"landuse": "military", "military": "training_area"}, "terms": ["air force", "army", "base", "fight", "fire", "force", "guard", "gun", "marine", "navy", "rifle", "shoot*", "snip*", "train", "troop", "war"], "name": "Training Area"},
"landuse/orchard": {"icon": "maki-park", "fields": ["name", "operator", "trees"], "moreFields": ["address", "website", "phone", "email", "fax"], "geometry": ["area"], "tags": {"landuse": "orchard"}, "terms": ["fruit"], "name": "Orchard"},
"landuse/orchard": {"icon": "maki-park", "fields": ["name", "operator", "trees"], "moreFields": ["address", "email", "fax", "phone", "species/wikidata", "website"], "geometry": ["area"], "tags": {"landuse": "orchard"}, "terms": ["fruit"], "name": "Orchard"},
"landuse/plant_nursery": {"icon": "maki-garden", "fields": ["name", "operator", "plant"], "moreFields": ["address", "website", "phone", "email", "fax"], "geometry": ["area"], "tags": {"landuse": "plant_nursery"}, "terms": ["flower", "garden", "grow", "vivero"], "name": "Plant Nursery"},
"landuse/quarry": {"geometry": ["area"], "fields": ["name", "operator", "resource"], "moreFields": ["address", "website", "phone", "email", "fax"], "tags": {"landuse": "quarry"}, "terms": [], "name": "Quarry"},
"landuse/railway": {"icon": "maki-rail", "fields": ["operator"], "geometry": ["area"], "tags": {"landuse": "railway"}, "terms": ["rail", "train", "track"], "name": "Railway Corridor"},
@@ -773,7 +773,7 @@
"natural/spring": {"icon": "maki-water", "fields": ["name", "intermittent"], "geometry": ["point", "vertex"], "tags": {"natural": "spring"}, "terms": [], "name": "Spring"},
"natural/stone": {"icon": "temaki-boulder1", "fields": ["name"], "geometry": ["point", "area"], "tags": {"natural": "stone"}, "terms": ["boulder", "stone", "rock"], "name": "Unattached Stone / Boulder"},
"natural/tree_row": {"icon": "maki-park", "fields": ["leaf_type", "leaf_cycle", "denotation"], "geometry": ["line"], "tags": {"natural": "tree_row"}, "terms": [], "name": "Tree Row"},
"natural/tree": {"icon": "maki-park", "fields": ["leaf_type_singular", "leaf_cycle_singular", "denotation", "diameter"], "geometry": ["point", "vertex"], "tags": {"natural": "tree"}, "terms": [], "name": "Tree"},
"natural/tree": {"icon": "maki-park", "fields": ["leaf_type_singular", "leaf_cycle_singular", "denotation", "diameter"], "moreFields": ["species/wikidata"], "geometry": ["point", "vertex"], "tags": {"natural": "tree"}, "terms": [], "name": "Tree"},
"natural/valley": {"icon": "maki-triangle-stroked", "fields": ["name", "elevation", "description"], "geometry": ["vertex", "point", "line"], "tags": {"natural": "valley"}, "terms": ["canyon", "dale", "dell", "dene", "depression", "glen", "gorge", "gully", "gulley", "gultch", "hollow", "ravine", "rift", "vale"], "name": "Valley"},
"natural/volcano": {"icon": "maki-volcano", "fields": ["name", "elevation", "volcano/status", "volcano/type"], "geometry": ["point", "vertex"], "tags": {"natural": "volcano"}, "terms": ["mountain", "crater"], "name": "Volcano"},
"natural/water": {"icon": "maki-water", "fields": ["name", "water", "intermittent"], "moreFields": ["fishing", "salt", "tidal"], "geometry": ["area"], "tags": {"natural": "water"}, "name": "Water"},
+2 -1
View File
@@ -2,7 +2,8 @@
"icon": "maki-zoo",
"fields": [
"name",
"operator"
"operator",
"species/wikidata"
],
"geometry": [
"point",
+4 -3
View File
@@ -7,10 +7,11 @@
],
"moreFields": [
"address",
"website",
"phone",
"email",
"fax"
"fax",
"phone",
"species/wikidata",
"website"
],
"geometry": [
"area"
+3
View File
@@ -6,6 +6,9 @@
"denotation",
"diameter"
],
"moreFields": [
"species/wikidata"
],
"geometry": [
"point",
"vertex"
+2
View File
@@ -1679,6 +1679,8 @@
{"key": "social_facility:for", "description": "🄵 People Served"},
{"key": "social_facility", "description": "🄵 Type"},
{"key": "source", "description": "🄵 Sources"},
{"key": "species:wikidata", "description": "🄵 Species Wikidata"},
{"key": "species:wikipedia", "description": "🄵 Species Wikidata"},
{"key": "sport", "description": "🄵 Sports"},
{"key": "stars", "description": "🄵 Stars"},
{"key": "start_date", "description": "🄵 Start Date"},
+3
View File
@@ -4020,6 +4020,9 @@
"source": {
"label": "Sources"
},
"species/wikidata": {
"label": "Species Wikidata"
},
"sport_ice": {
"label": "Sports"
},
+36 -29
View File
@@ -29,6 +29,11 @@ export function uiFieldWikidata(field, context) {
var _wikiURL = '';
var _entity;
var _wikipediaKey = field.keys && field.keys.find(function(key) {
return key.includes('wikipedia');
}),
_hintKey = field.key === 'wikidata' ? 'name' : field.key.split(':')[0];
var combobox = uiCombobox(context, 'combo-' + field.safeid)
.caseSensitive(true)
.minItems(1);
@@ -137,7 +142,7 @@ export function uiFieldWikidata(field, context) {
function fetchWikidataItems(q, callback) {
if (!q && _entity) {
q = context.entity(_entity.id).tags.name || '';
q = (_hintKey && context.entity(_entity.id).tags[_hintKey]) || '';
}
wikidata.itemsForSearchQuery(q, function(err, data) {
@@ -186,35 +191,37 @@ export function uiFieldWikidata(field, context) {
var currTags = Object.assign({}, context.entity(initEntityID).tags); // shallow copy
var foundPreferred;
for (var i in langs) {
var lang = langs[i];
var siteID = lang.replace('-', '_') + 'wiki';
if (entity.sitelinks[siteID]) {
foundPreferred = true;
currTags.wikipedia = lang + ':' + entity.sitelinks[siteID].title;
// use the first match
break;
}
}
if (!foundPreferred) {
// No wikipedia sites available in the user's language or the fallback languages,
// default to any wikipedia sitelink
var wikiSiteKeys = Object.keys(entity.sitelinks).filter(function(site) {
return site.endsWith('wiki');
});
if (wikiSiteKeys.length === 0) {
// if no wikipedia pages are linked to this wikidata entity, delete that tag
if (currTags.wikipedia) {
delete currTags.wikipedia;
if (_wikipediaKey) {
var foundPreferred;
for (var i in langs) {
var lang = langs[i];
var siteID = lang.replace('-', '_') + 'wiki';
if (entity.sitelinks[siteID]) {
foundPreferred = true;
currTags[_wikipediaKey] = lang + ':' + entity.sitelinks[siteID].title;
// use the first match
break;
}
}
if (!foundPreferred) {
// No wikipedia sites available in the user's language or the fallback languages,
// default to any wikipedia sitelink
var wikiSiteKeys = Object.keys(entity.sitelinks).filter(function(site) {
return site.endsWith('wiki');
});
if (wikiSiteKeys.length === 0) {
// if no wikipedia pages are linked to this wikidata entity, delete that tag
if (currTags[_wikipediaKey]) {
delete currTags[_wikipediaKey];
}
} else {
var wikiLang = wikiSiteKeys[0].slice(0, -4).replace('_', '-');
var wikiTitle = entity.sitelinks[wikiSiteKeys[0]].title;
currTags[_wikipediaKey] = wikiLang + ':' + wikiTitle;
}
} else {
var wikiLang = wikiSiteKeys[0].slice(0, -4).replace('_', '-');
var wikiTitle = entity.sitelinks[wikiSiteKeys[0]].title;
currTags.wikipedia = wikiLang + ':' + wikiTitle;
}
}