Skip to content

Commit

Permalink
Don't say tags imply area for tags that iD doesn't have a preset for (c…
Browse files Browse the repository at this point in the history
…lose #5933)
  • Loading branch information
quincylvania committed Feb 25, 2019
1 parent 0e71ae7 commit 12b1af7
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 121 deletions.
8 changes: 4 additions & 4 deletions data/presets/presets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
"presets": {
"aerialway": {"fields": ["aerialway"], "geometry": ["point", "vertex", "line"], "tags": {"aerialway": "*"}, "searchable": false, "name": "Aerialway"},
"aeroway": {"icon": "maki-airport", "fields": ["aeroway"], "geometry": ["point", "vertex", "line", "area"], "tags": {"aeroway": "*"}, "searchable": false, "name": "Aeroway"},
"amenity": {"fields": ["amenity"], "geometry": ["point", "vertex", "area"], "tags": {"amenity": "*"}, "searchable": false, "name": "Amenity"},
"amenity": {"fields": ["amenity"], "geometry": ["point", "vertex", "line", "area"], "tags": {"amenity": "*"}, "searchable": false, "name": "Amenity"},
"attraction": {"icon": "maki-star", "fields": ["name", "attraction", "operator", "opening_hours"], "moreFields": ["opening_hours", "fee", "payment_multi", "address", "website", "phone", "email", "fax"], "geometry": ["point", "vertex", "line", "area"], "tags": {"attraction": "*"}, "searchable": false, "name": "Attraction"},
"boundary": {"fields": ["boundary"], "geometry": ["line"], "tags": {"boundary": "*"}, "searchable": false, "name": "Boundary"},
"circular": {"geometry": ["vertex", "line"], "fields": ["name"], "tags": {"junction": "circular"}, "name": "Traffic Circle", "searchable": false},
"embankment": {"geometry": ["line"], "tags": {"embankment": "yes"}, "name": "Embankment", "matchScore": 0.2, "searchable": false},
"highway": {"fields": ["name", "highway"], "geometry": ["point", "vertex", "line", "area"], "tags": {"highway": "*"}, "searchable": false, "name": "Highway"},
"landuse": {"fields": ["name", "landuse"], "geometry": ["area"], "tags": {"landuse": "*"}, "matchScore": 0.9, "searchable": false, "name": "Land Use"},
"leisure": {"icon": "maki-pitch", "fields": ["name", "leisure"], "geometry": ["point", "vertex", "area"], "tags": {"leisure": "*"}, "searchable": false, "name": "Leisure"},
"leisure": {"icon": "maki-pitch", "fields": ["name", "leisure"], "geometry": ["point", "vertex", "line", "area"], "tags": {"leisure": "*"}, "searchable": false, "name": "Leisure"},
"man_made": {"icon": "temaki-storage_tank", "fields": ["name", "man_made"], "moreFields": ["material"], "geometry": ["point", "vertex", "line", "area"], "tags": {"man_made": "*"}, "searchable": false, "name": "Man Made"},
"natural": {"icon": "maki-natural", "fields": ["name", "natural"], "geometry": ["point", "vertex", "area"], "tags": {"natural": "*"}, "searchable": false, "name": "Natural"},
"natural": {"icon": "maki-natural", "fields": ["name", "natural"], "geometry": ["point", "vertex", "line", "area"], "tags": {"natural": "*"}, "searchable": false, "name": "Natural"},
"place": {"fields": ["name", "place"], "geometry": ["point", "vertex", "area"], "tags": {"place": "*"}, "searchable": false, "name": "Place"},
"power": {"geometry": ["point", "vertex", "line", "area"], "tags": {"power": "*"}, "fields": ["power"], "moreFields": ["material"], "searchable": false, "name": "Power"},
"railway": {"fields": ["railway"], "geometry": ["point", "vertex", "line", "area"], "tags": {"railway": "*"}, "searchable": false, "name": "Railway"},
"roundabout": {"geometry": ["vertex", "line"], "fields": ["name"], "tags": {"junction": "roundabout"}, "name": "Roundabout", "searchable": false},
"seamark": {"icon": "maki-harbor", "fields": ["seamark/type"], "geometry": ["point", "vertex", "line", "area"], "tags": {"seamark:type": "*"}, "searchable": false, "name": "Seamark"},
"tourism": {"icon": "maki-attraction", "fields": ["name", "tourism"], "geometry": ["point", "vertex", "area"], "tags": {"tourism": "*"}, "searchable": false, "name": "Tourism"},
"tourism": {"icon": "maki-attraction", "fields": ["name", "tourism"], "geometry": ["point", "vertex", "line", "area"], "tags": {"tourism": "*"}, "searchable": false, "name": "Tourism"},
"waterway": {"fields": ["name", "waterway"], "geometry": ["point", "vertex", "line", "area"], "tags": {"waterway": "*"}, "searchable": false, "name": "Waterway"},
"address": {"fields": ["address"], "geometry": ["point", "vertex", "area"], "tags": {"addr:*": "*"}, "addTags": {}, "removeTags": {}, "reference": {"key": "addr"}, "name": "Address", "matchScore": 0.15},
"advertising/billboard": {"fields": ["direction", "lit"], "geometry": ["point", "vertex", "line"], "tags": {"advertising": "billboard"}, "name": "Billboard"},
Expand Down
3 changes: 2 additions & 1 deletion data/presets/presets/_amenity.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
"geometry": [
"point",
"vertex",
"line",
"area"
],
"tags": {
"amenity": "*"
},
"searchable": false,
"name": "Amenity"
}
}
1 change: 1 addition & 0 deletions data/presets/presets/_leisure.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"geometry": [
"point",
"vertex",
"line",
"area"
],
"tags": {
Expand Down
1 change: 1 addition & 0 deletions data/presets/presets/_natural.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"geometry": [
"point",
"vertex",
"line",
"area"
],
"tags": {
Expand Down
1 change: 1 addition & 0 deletions data/presets/presets/_tourism.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"geometry": [
"point",
"vertex",
"line",
"area"
],
"tags": {
Expand Down
8 changes: 4 additions & 4 deletions data/taginfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
"tags": [
{"key": "aerialway", "description": "🄿 Aerialway (unsearchable), 🄵 Type", "object_types": ["node", "way"]},
{"key": "aeroway", "description": "🄿 Aeroway (unsearchable), 🄵 Type", "object_types": ["node", "way", "area"], "icon_url": "https://raw.githubusercontent.com/mapbox/maki/master/icons/airport-15.svg?sanitize=true"},
{"key": "amenity", "description": "🄿 Amenity (unsearchable), 🄵 Type", "object_types": ["node", "area"]},
{"key": "amenity", "description": "🄿 Amenity (unsearchable), 🄵 Type", "object_types": ["node", "way", "area"]},
{"key": "attraction", "description": "🄿 Attraction (unsearchable), 🄵 Type", "object_types": ["node", "way", "area"], "icon_url": "https://raw.githubusercontent.com/mapbox/maki/master/icons/star-15.svg?sanitize=true"},
{"key": "boundary", "description": "🄿 Boundary (unsearchable), 🄵 Type", "object_types": ["way"]},
{"key": "junction", "value": "circular", "description": "🄿 Traffic Circle (unsearchable), 🄵 Junction", "object_types": ["node", "way"]},
{"key": "embankment", "value": "yes", "description": "🄿 Embankment (unsearchable)", "object_types": ["way"]},
{"key": "highway", "description": "🄿 Highway (unsearchable), 🄵 Type", "object_types": ["node", "way", "area"]},
{"key": "landuse", "description": "🄿 Land Use (unsearchable), 🄵 Type", "object_types": ["area"]},
{"key": "leisure", "description": "🄿 Leisure (unsearchable), 🄵 Type", "object_types": ["node", "area"], "icon_url": "https://raw.githubusercontent.com/mapbox/maki/master/icons/pitch-15.svg?sanitize=true"},
{"key": "leisure", "description": "🄿 Leisure (unsearchable), 🄵 Type", "object_types": ["node", "way", "area"], "icon_url": "https://raw.githubusercontent.com/mapbox/maki/master/icons/pitch-15.svg?sanitize=true"},
{"key": "man_made", "description": "🄿 Man Made (unsearchable), 🄵 Type", "object_types": ["node", "way", "area"], "icon_url": "https://raw.githubusercontent.com/bhousel/temaki/master/icons/storage_tank.svg?sanitize=true"},
{"key": "natural", "description": "🄿 Natural (unsearchable), 🄵 Natural", "object_types": ["node", "area"], "icon_url": "https://raw.githubusercontent.com/mapbox/maki/master/icons/natural-15.svg?sanitize=true"},
{"key": "natural", "description": "🄿 Natural (unsearchable), 🄵 Natural", "object_types": ["node", "way", "area"], "icon_url": "https://raw.githubusercontent.com/mapbox/maki/master/icons/natural-15.svg?sanitize=true"},
{"key": "place", "description": "🄿 Place (unsearchable), 🄵 Type", "object_types": ["node", "area"]},
{"key": "power", "description": "🄿 Power (unsearchable), 🄵 Type", "object_types": ["node", "way", "area"]},
{"key": "railway", "description": "🄿 Railway (unsearchable), 🄵 Type", "object_types": ["node", "way", "area"]},
{"key": "junction", "value": "roundabout", "description": "🄿 Roundabout (unsearchable), 🄵 Junction", "object_types": ["node", "way"]},
{"key": "seamark:type", "description": "🄿 Seamark (unsearchable), 🄵 Seamark", "object_types": ["node", "way", "area"], "icon_url": "https://raw.githubusercontent.com/mapbox/maki/master/icons/harbor-15.svg?sanitize=true"},
{"key": "tourism", "description": "🄿 Tourism (unsearchable), 🄵 Type", "object_types": ["node", "area"], "icon_url": "https://raw.githubusercontent.com/mapbox/maki/master/icons/attraction-15.svg?sanitize=true"},
{"key": "tourism", "description": "🄿 Tourism (unsearchable), 🄵 Type", "object_types": ["node", "way", "area"], "icon_url": "https://raw.githubusercontent.com/mapbox/maki/master/icons/attraction-15.svg?sanitize=true"},
{"key": "waterway", "description": "🄿 Waterway (unsearchable), 🄵 Type", "object_types": ["node", "way", "area"]},
{"key": "addr:*", "description": "🄿 Address", "object_types": ["node", "area"]},
{"key": "advertising", "value": "billboard", "description": "🄿 Billboard", "object_types": ["node", "way"]},
Expand Down
2 changes: 1 addition & 1 deletion modules/osm/way.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ _extend(osmWay.prototype, {
return true;
},

// returns an objects with the tag that implies this is an area, if any
// returns an object with the tag that implies this is an area, if any
tagSuggestingArea: function() {

if (this.tags.area === 'yes') return { area: 'yes' };
Expand Down
55 changes: 30 additions & 25 deletions modules/presets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,42 +40,47 @@ export function presetIndex() {
all.match = function(entity, resolver) {
return resolver.transient(entity, 'presetMatch', function() {
var geometry = entity.geometry(resolver);
var address;

// Treat entities on addr:interpolation lines as points, not vertices - #3241
if (geometry === 'vertex' && entity.isOnAddressLine(resolver)) {
geometry = 'point';
}

var geometryMatches = _index[geometry];
var best = -1;
var match;
return all.matchTags(entity.tags, geometry);
});
};

for (var k in entity.tags) {
// If any part of an address is present,
// allow fallback to "Address" preset - #4353
if (/^addr:/.test(k) && geometryMatches['addr:*']) {
address = geometryMatches['addr:*'][0];
}
all.matchTags = function(tags, geometry) {

var keyMatches = geometryMatches[k];
if (!keyMatches) continue;

for (var i = 0; i < keyMatches.length; i++) {
var score = keyMatches[i].matchScore(entity);
if (score > best) {
best = score;
match = keyMatches[i];
}
}
var address;
var geometryMatches = _index[geometry];
var best = -1;
var match;

for (var k in tags) {
// If any part of an address is present,
// allow fallback to "Address" preset - #4353
if (/^addr:/.test(k) && geometryMatches['addr:*']) {
address = geometryMatches['addr:*'][0];
}

if (address && (!match || match.isFallback())) {
match = address;
var keyMatches = geometryMatches[k];
if (!keyMatches) continue;

for (var i = 0; i < keyMatches.length; i++) {
var score = keyMatches[i].matchScore(tags);
if (score > best) {
best = score;
match = keyMatches[i];
}
}
return match || all.item(geometry);
});

}

if (address && (!match || match.isFallback())) {
match = address;
}
return match || all.item(geometry);
};

all.allowsVertex = function(entity, resolver) {
Expand All @@ -93,7 +98,7 @@ export function presetIndex() {
didFindMatches = true;
for (var i = 0; i < keyMatches.length; i++) {
var preset = keyMatches[i];
if (preset.searchable !== false && preset.matchScore(entity) > -1) {
if (preset.searchable !== false && preset.matchScore(entity.tags) > -1) {
return preset;
}
}
Expand Down
6 changes: 3 additions & 3 deletions modules/presets/preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ export function presetPreset(id, preset, fields, visible, rawPresets) {
preset.originalScore = preset.matchScore || 1;


preset.matchScore = function(entity) {
preset.matchScore = function(entityTags) {
var tags = preset.tags;
var score = 0;

for (var t in tags) {
if (entity.tags[t] === tags[t]) {
if (entityTags[t] === tags[t]) {
score += preset.originalScore;
} else if (tags[t] === '*' && t in entity.tags) {
} else if (tags[t] === '*' && t in entityTags) {
score += preset.originalScore / 2;
} else {
return -1;
Expand Down
Loading

0 comments on commit 12b1af7

Please sign in to comment.