Moved area-keys to data, and process it during runtime

This commit is contained in:
Sajjad Anwar
2014-10-22 18:24:09 -04:00
committed by John Firebaugh
parent 90b0f1c5bf
commit dffeedffc9
8 changed files with 59 additions and 113 deletions
-92
View File
@@ -1,92 +0,0 @@
/* jshint -W109 */
iD.areaKeys = {
"aeroway": {
"gate": true,
"taxiway": true
},
"amenity": {
"atm": true,
"bbq": true,
"bench": true,
"bureau_de_change": true,
"clock": true,
"drinking_water": true,
"parking_entrance": true,
"post_box": true,
"telephone": true,
"vending_machine": true,
"waste_basket": true
},
"area": {},
"barrier": {
"block": true,
"bollard": true,
"cattle_grid": true,
"cycle_barrier": true,
"entrance": true,
"fence": true,
"gate": true,
"kissing_gate": true,
"lift_gate": true,
"stile": true,
"toll_booth": true
},
"building": {
"entrance": true
},
"craft": {},
"emergency": {
"fire_hydrant": true,
"phone": true
},
"golf": {
"hole": true
},
"historic": {
"boundary_stone": true
},
"landuse": {},
"leisure": {
"picnic_table": true,
"track": true,
"slipway": true
},
"man_made": {
"cutline": true,
"embankment": true,
"flagpole": true,
"pipeline": true,
"survey_point": true
},
"military": {},
"natural": {
"coastline": true,
"peak": true,
"spring": true,
"tree": true
},
"office": {},
"piste:type": {},
"place": {},
"power": {
"line": true,
"minor_line": true,
"pole": true,
"tower": true
},
"public_transport": {
"stop_position": true
},
"shop": {},
"tourism": {
"viewpoint": true
},
"waterway": {
"canal": true,
"ditch": true,
"drain": true,
"river": true,
"stream": true,
"weir": true
}
};
+1
View File
@@ -227,6 +227,7 @@ window.iD = function () {
context.presets = function(_) {
if (!arguments.length) return presets;
presets.load(_);
iD.areaKeys = presets.areaKeys();
return context;
};
+26
View File
@@ -40,6 +40,32 @@ iD.presets = function() {
return match || all.item(geometry);
};
all.areaKeys = function() {
// A closed way is considered to be an area if it has a tag with one
// of the following keys, and the value is _not_ one of the associated
// values for the respective key.
var areaKeys = {};
all.collection.forEach(function(d) {
if (d.tags) {
for (var key in d.tags) break;
var value = d.tags[key];
if (['highway', 'footway', 'railway', 'type'].indexOf(key) === -1) {
if (d.geometry.indexOf('area') >= 0) {
areaKeys[key] = areaKeys[key] || {};
} else if (key in areaKeys && value !== '*') {
areaKeys[key][value] = true;
}
}
}
});
return areaKeys;
};
all.load = function(d) {
if (d.fields) {