If any part of an address is present, allow fallback to "Address" preset

(closes #4353)
This commit is contained in:
Bryan Housel
2017-09-19 16:55:18 -04:00
parent 04352bb15d
commit 7b9af48c4d
6 changed files with 41 additions and 16 deletions
+1 -1
View File
@@ -1465,7 +1465,7 @@ en:
label: Wikipedia
presets:
address:
# 'addr:housenumber=*'
# 'addr:*=*'
name: Address
terms: '<translate with synonyms or related terms for ''Address'', separated by commas>'
advertising/billboard:
+11 -8
View File
@@ -158,12 +158,15 @@
"area"
],
"tags": {
"addr:housenumber": "*"
"addr:*": "*"
},
"addTags": {},
"removeTags": {},
"reference": {
"key": "addr"
},
"name": "Address",
"matchScore": 0.3
"matchScore": 0.15
},
"advertising/billboard": {
"fields": [
@@ -12109,16 +12112,16 @@
"name": "Tram"
},
"relation": {
"name": "Relation",
"icon": "relation",
"tags": {},
"geometry": [
"relation"
],
"fields": [
"name",
"relation"
]
],
"geometry": [
"relation"
],
"tags": {},
"name": "Relation"
},
"route/ferry": {
"icon": "ferry-line",
+5 -2
View File
@@ -8,10 +8,13 @@
"area"
],
"tags": {
"addr:housenumber": "*"
"addr:*": "*"
},
"addTags": {},
"removeTags": {},
"reference": {
"key": "addr"
},
"name": "Address",
"matchScore": 0.3
"matchScore": 0.15
}
+1 -1
View File
@@ -41,7 +41,7 @@
"key": "waterway"
},
{
"key": "addr:housenumber"
"key": "addr:*"
},
{
"key": "advertising",
+12 -1
View File
@@ -32,8 +32,9 @@ export function presetIndex() {
all.match = function(entity, resolver) {
var geometry = entity.geometry(resolver);
var address;
// Treat entities on addr:interpolation lines as points, not vertices (#3241)
// Treat entities on addr:interpolation lines as points, not vertices - #3241
if (geometry === 'vertex' && entity.isOnAddressLine(resolver)) {
geometry = 'point';
}
@@ -43,6 +44,12 @@ export function presetIndex() {
match;
for (var k in entity.tags) {
// If any part of an address is present,
// allow fallback to "Address" preset - #4353
if (k.match(/^addr:/) !== null && geometryMatches['addr:*']) {
address = geometryMatches['addr:*'][0];
}
var keyMatches = geometryMatches[k];
if (!keyMatches) continue;
@@ -55,6 +62,10 @@ export function presetIndex() {
}
}
if (address && (!match || match.isFallback())) {
match = address;
}
return match || all.item(geometry);
};
+11 -3
View File
@@ -183,11 +183,19 @@ export function uiEntityEditor(context) {
function historyChanged() {
if (state === 'hide') return;
var entity = context.hasEntity(entityId),
graph = context.graph();
var entity = context.hasEntity(entityId);
var graph = context.graph();
if (!entity) return;
entityEditor.preset(context.presets().match(entity, graph));
var match = context.presets().match(entity, graph);
var activePreset = entityEditor.preset();
var weakPreset = activePreset && _.isEmpty(activePreset.addTags);
// A "weak" preset doesn't set any tags. (e.g. "Address")
// Don't replace a weak preset with a fallback preset (e.g. "Point")
if (!(weakPreset && match.isFallback())) {
entityEditor.preset(match);
}
entityEditor.modified(base !== graph);
entityEditor(selection);
}