some geometry inferring!!!

ref #remote-presets
This commit is contained in:
Max Grossman
2018-08-08 08:50:45 -04:00
parent b93444de75
commit f5c21ddaaf
3 changed files with 44 additions and 45 deletions
+9 -9
View File
@@ -7,7 +7,7 @@ import _isObject from 'lodash-es/isObject';
import _isString from 'lodash-es/isString';
import _map from 'lodash-es/map';
import mapcssParse from 'mapcss-parse';
// import mapcssParse from 'mapcss-parse';
import { dispatch as d3_dispatch } from 'd3-dispatch';
@@ -457,14 +457,14 @@ export function coreContext() {
locale = locale.split('-')[0];
}
if (utilExternalValidationRules()) {
var validationsUrl = utilStringQs(window.location.hash).validations;
d3_text(validationsUrl, function (err, mapcss) {
if (err) return;
var validations = _map(mapcssParse(mapcss), function(mapcssConfig) { return utilMapCSSRule(mapcssConfig, context.presets().areaKeys()); });
context.validationRules = function() { return validations; };
});
}
// if (utilExternalValidationRules()) {
// var validationsUrl = utilStringQs(window.location.hash).validations;
// d3_text(validationsUrl, function (err, mapcss) {
// if (err) return;
// var validations = _map(mapcssParse(mapcss), function(mapcssConfig) { return utilMapCSSRule(mapcssConfig, context.presets().areaKeys()); });
// context.validationRules = function() { return validations; };
// });
// }
history = coreHistory(context);
context.graph = history.graph;
-1
View File
@@ -121,7 +121,6 @@ export function presetIndex() {
areaKeys[key][value] = true;
}
});
console.log(areaKeys);
return areaKeys;
};
+35 -35
View File
@@ -1,5 +1,5 @@
import _isMatch from 'lodash-es/isMatch';
import _reduce from 'lodash-es/reduce';
import _intersection from 'lodash-es/intersection';
export function utilMapCSSRule(selector, areaKeys) {
var ruleChecks = {
@@ -63,53 +63,53 @@ export function utilMapCSSRule(selector, areaKeys) {
},
// borrowed from Way#isArea()
inferGeometry() {
// keys is a map of osm key + all found values across the selector map.
var selectorKeys = _reduce(Object.keys(selector), function(expectedTags, key) {
var values;
if(/regex/gi.test(key)) {
Object.keys(p[key]).forEach(function(regexKey) {
values = p[key][rKey].map(function(val) { return val.replace(/\$|\^/g, '') })
if (expectedTags.hasOwnProperty(regexKey)) {
values = values.concat(expectedTags[regexKey])
}
expectedTags[regexKey] = values
})
}
if (key === 'equals') {
var equalsKey = Object.keys(p[key])[0]
values = [p[key][equalsKey]]
if (expectedTags.hasOwnProperty(equalsKey)) {
values = values.concat(expectedTags[equalsKey])
}
expectedTags[equalsKey] = values
inferGeometry: function (tagMap, areaKeys) {
var lineKeys = {
highway: {
rest_area: true,
services: true
},
railway: {
roundhouse: true,
station: true,
traverser: true,
turntable: true,
wash: true
}
return expectedTags
}, {})
};
var isAreaKeyBlackList = function(key) {
return _intersection(tagMap[key], Object.keys(areaKeys[key])).length > 0;
};
var isLineKeysWhiteList = function(key) {
return _intersection(tagMap[key], Object.keys(lineKeys[key])).length > 0;
};
if (Object.keys(keys).indexOf('area') > -1) {
inferredGeometry = 'area';
return;
if (tagMap.hasOwnProperty('area')) {
if (tagMap.area.indexOf('yes') > -1) {
return 'area';
}
if (tagMap.area.indexOf('no') > -1) {
return 'line';
}
}
for (var key in Object.keys(keys)) {
if (key in areaKeys) {
if (keys[key] !== 'absence' && key in ) {
}
for (var key in tagMap) {
if (key in areaKeys && !isAreaKeyBlackList(key)) {
return 'area';
}
if (key in lineKeys && isLineKeysWhiteList(key)) {
return 'area';
}
}
return 'line';
},
geometryMatches: function(entity, graph) {
if (entity.type === 'node' || entity.type === 'relation') {
return selector.geometry === entity.type;
} else if (entity.type === 'way') {
return this.inferGeometry() === entity.geometry(graph);
return 'area' === entity.geometry(graph);
}
},
findWarnings: function (entity, graph, warnings) {
if (this.geometryMatches(entity, graph) && this.matches(entity)) {