Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getPropertyFromFilter(filter, properties) {
if (styleSpec.expression.isExpression(filter)) {
getPropertyFromExpression(filter, properties);
}
// Warning: Below code should put in to an else conditions,
// but since the `isExpression` can not tell it is a expression or filter syntax I put it outsied the else
// this could reduce the performance or cause some potential bugs, we must keep an eye on this.
// else {
let subFilter = [];
for (let i = 0; i < filter.length; i++) {
if (typeof filter[i] === 'object' && filter[i] instanceof Array) {
subFilter.push(filter[i]);
}
}
if (subFilter.length > 0) {
// - special properties: `mapbox_clip_start`, `mapbox_clip_end`
if (typeof value === 'string') {
// if the value is string try to get property name from `xx{PropertyName}xx` like.
// the /{[^}]+}/ig return all the value like {xxx}
// eg 'a{hello}badfa' => ['{hello}']
// eg 'a{hello}ba{world}dfa' => ['{hello}','{world}']
let preProperties = value.match(/{[^}]+}/ig);
preProperties && preProperties.forEach(item => {
properties.push(item.slice(1, -1));
});
} else if (typeof value === 'object' && typeof value.property === 'string') {
// - legacy functions with `property`
properties.push(value.property);
} else {
// test isExpression from sytleSpec
if (styleSpec.expression.isExpression(value)) {
// TODO: now we implement this by ourself in vtshavem, we need to talk with ‘style spec’ member to see if there have a official method to get used property, to make this can be synchronized with the expression update.
getPropertyFromExpression(value, properties);
} else {
// otherwise continual loop;
getPropertyFromLayoutAndPainter(value, properties);
}
}
})
}
export function filterFeatures(features, filter, inverse = true) {
const new_features = [];
// the createFilter function is from mapbox!
// uses the mapbox gl style filters.
let filter_function = function() { return true; };
if (filter !== undefined && filter !== null ) {
filter_function = createFilter(['all'].concat(filter));
}
for(const feature of features) {
if(inverse !== filter_function(feature)) {
new_features.push(feature);
}
}
return new_features;
}
.then(function(data) {
var json = simpleExpr.compile(data)
var out = mgl.expression.createExpression(json, {})
var result = out.value.evaluate(globalOpts, {
id: argv["feature-id"],
type: argv["feature-type"],
properties: featureOpts
})
console.log(result);
process.exit(0);
})
.catch(handleError)
/*
Generates the list of paint and layout properties from the Mapbox-GL-JS style spec.
Should be run when new properties are added to that spec.
*/
const v8 = require('@mapbox/mapbox-gl-style-spec/reference/v8.json');
const fs = require('fs');
const out = {
paints: [],
layouts: []
};
Object.keys(v8)
.filter(x => /^paint_/.test(x))
.forEach(key => out.paints.push(...Object.keys(v8[key])));
Object.keys(v8)
.filter(x => /^layout_/.test(x))
.forEach(key => out.layouts.push(...Object.keys(v8[key])));
out.paints = Array.from(new Set(out.paints));
out.layouts = Array.from(new Set(out.layouts));
fs.writeFileSync('keys.json', JSON.stringify(out));
/*
Generates the list of paint and layout properties from the Mapbox-GL-JS style spec.
Should be run when new properties are added to that spec.
*/
const v8 = require('@mapbox/mapbox-gl-style-spec/reference/v8.json');
const fs = require('fs');
const out = {
paints: [],
layouts: []
};
Object.keys(v8)
.filter(x => /^paint_/.test(x))
.forEach(key => out.paints.push(...Object.keys(v8[key])));
Object.keys(v8)
.filter(x => /^layout_/.test(x))
.forEach(key => out.layouts.push(...Object.keys(v8[key])));
out.paints = Array.from(new Set(out.paints));
out.layouts = Array.from(new Set(out.layouts));
fs.writeFileSync('keys.json', JSON.stringify(out));
render() {
return
}
}
render() {
return
[src, src])}
/>
}
}
render() {
return
}
}
render() {
return
}
}