You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.7 KiB
60 lines
1.7 KiB
// @flow
|
|
|
|
import CompoundExpression from './compound_expression.js';
|
|
import Within from './definitions/within.js';
|
|
import type {Expression} from './expression.js';
|
|
|
|
function isFeatureConstant(e: Expression): boolean {
|
|
if (e instanceof CompoundExpression) {
|
|
if (e.name === 'get' && e.args.length === 1) {
|
|
return false;
|
|
} else if (e.name === 'feature-state') {
|
|
return false;
|
|
} else if (e.name === 'has' && e.args.length === 1) {
|
|
return false;
|
|
} else if (
|
|
e.name === 'properties' ||
|
|
e.name === 'geometry-type' ||
|
|
e.name === 'id'
|
|
) {
|
|
return false;
|
|
} else if (/^filter-/.test(e.name)) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
if (e instanceof Within) {
|
|
return false;
|
|
}
|
|
|
|
let result = true;
|
|
e.eachChild(arg => {
|
|
if (result && !isFeatureConstant(arg)) { result = false; }
|
|
});
|
|
return result;
|
|
}
|
|
|
|
function isStateConstant(e: Expression): boolean {
|
|
if (e instanceof CompoundExpression) {
|
|
if (e.name === 'feature-state') {
|
|
return false;
|
|
}
|
|
}
|
|
let result = true;
|
|
e.eachChild(arg => {
|
|
if (result && !isStateConstant(arg)) { result = false; }
|
|
});
|
|
return result;
|
|
}
|
|
|
|
function isGlobalPropertyConstant(e: Expression, properties: Array<string>): boolean {
|
|
if (e instanceof CompoundExpression && properties.indexOf(e.name) >= 0) { return false; }
|
|
let result = true;
|
|
e.eachChild((arg) => {
|
|
if (result && !isGlobalPropertyConstant(arg, properties)) { result = false; }
|
|
});
|
|
return result;
|
|
}
|
|
|
|
export {isFeatureConstant, isGlobalPropertyConstant, isStateConstant};
|