2021-03-29 00:41:53 +02:00
|
|
|
import {TagsFilter} from "../../Logic/Tags/TagsFilter";
|
2021-03-20 23:45:52 +01:00
|
|
|
|
|
|
|
export default class SourceConfig {
|
|
|
|
|
|
|
|
osmTags?: TagsFilter;
|
|
|
|
overpassScript?: string;
|
|
|
|
geojsonSource?: string;
|
2021-04-22 03:30:46 +02:00
|
|
|
geojsonZoomLevel?: number;
|
2021-05-14 02:25:30 +02:00
|
|
|
isOsmCacheLayer: boolean;
|
2021-03-20 23:45:52 +01:00
|
|
|
|
|
|
|
constructor(params: {
|
|
|
|
osmTags?: TagsFilter,
|
|
|
|
overpassScript?: string,
|
2021-04-22 03:30:46 +02:00
|
|
|
geojsonSource?: string,
|
2021-05-14 02:25:30 +02:00
|
|
|
isOsmCache?: boolean,
|
2021-04-22 03:30:46 +02:00
|
|
|
geojsonSourceLevel?: number
|
2021-05-14 02:25:30 +02:00
|
|
|
}, context?: string) {
|
2021-03-20 23:45:52 +01:00
|
|
|
|
|
|
|
let defined = 0;
|
|
|
|
if (params.osmTags) {
|
|
|
|
defined++;
|
|
|
|
}
|
|
|
|
if (params.overpassScript) {
|
|
|
|
defined++;
|
|
|
|
}
|
|
|
|
if (params.geojsonSource) {
|
|
|
|
defined++;
|
|
|
|
}
|
|
|
|
if (defined == 0) {
|
2021-05-17 00:31:10 +02:00
|
|
|
throw `Source: nothing correct defined in the source (in ${context}) (the params are ${JSON.stringify(params)})`
|
2021-03-20 23:45:52 +01:00
|
|
|
}
|
2021-08-07 23:11:34 +02:00
|
|
|
if (params.isOsmCache && params.geojsonSource == undefined) {
|
2021-05-14 02:25:30 +02:00
|
|
|
console.error(params)
|
|
|
|
throw `Source said it is a OSM-cached layer, but didn't define the actual source of the cache (in context ${context})`
|
|
|
|
}
|
2021-03-20 23:45:52 +01:00
|
|
|
this.osmTags = params.osmTags;
|
|
|
|
this.overpassScript = params.overpassScript;
|
|
|
|
this.geojsonSource = params.geojsonSource;
|
2021-04-22 03:30:46 +02:00
|
|
|
this.geojsonZoomLevel = params.geojsonSourceLevel;
|
2021-05-14 02:25:30 +02:00
|
|
|
this.isOsmCacheLayer = params.isOsmCache ?? false;
|
2021-03-20 23:45:52 +01:00
|
|
|
}
|
|
|
|
}
|