Add more documentation and checks to the models

This commit is contained in:
Pieter Vander Vennet 2021-09-18 02:32:40 +02:00
parent 706c5e3d53
commit 47011370dd
4 changed files with 22 additions and 4 deletions

View file

@ -104,6 +104,10 @@ export default class LayerConfig {
throw context + "Use 'geoJson' instead of 'geoJsonSource'";
}
if (json.source["geojson"] !== undefined) {
throw context + "Use 'geoJson' instead of 'geojson' (the J is a capital letter)";
}
this.source = new SourceConfig(
{
osmTags: osmTags,
@ -133,6 +137,14 @@ export default class LayerConfig {
const key = kv.substring(0, index);
const code = kv.substring(index + 1);
try{
new Function("feat", "return " + code + ";");
}catch(e){
throw `Invalid function definition: code ${code} is invalid:${e} (at ${context})`
}
this.calculatedTags.push([key, code]);
}
}