Refacotring: move themeConfig into models
This commit is contained in:
parent
0a01561d37
commit
647100bee5
79 changed files with 603 additions and 629 deletions
42
Models/ThemeConfig/SourceConfig.ts
Normal file
42
Models/ThemeConfig/SourceConfig.ts
Normal file
|
@ -0,0 +1,42 @@
|
|||
import {TagsFilter} from "../../Logic/Tags/TagsFilter";
|
||||
|
||||
export default class SourceConfig {
|
||||
|
||||
osmTags?: TagsFilter;
|
||||
overpassScript?: string;
|
||||
geojsonSource?: string;
|
||||
geojsonZoomLevel?: number;
|
||||
isOsmCacheLayer: boolean;
|
||||
|
||||
constructor(params: {
|
||||
osmTags?: TagsFilter,
|
||||
overpassScript?: string,
|
||||
geojsonSource?: string,
|
||||
isOsmCache?: boolean,
|
||||
geojsonSourceLevel?: number
|
||||
}, context?: string) {
|
||||
|
||||
let defined = 0;
|
||||
if (params.osmTags) {
|
||||
defined++;
|
||||
}
|
||||
if (params.overpassScript) {
|
||||
defined++;
|
||||
}
|
||||
if (params.geojsonSource) {
|
||||
defined++;
|
||||
}
|
||||
if (defined == 0) {
|
||||
throw `Source: nothing correct defined in the source (in ${context}) (the params are ${JSON.stringify(params)})`
|
||||
}
|
||||
if (params.isOsmCache && params.geojsonSource == undefined) {
|
||||
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})`
|
||||
}
|
||||
this.osmTags = params.osmTags;
|
||||
this.overpassScript = params.overpassScript;
|
||||
this.geojsonSource = params.geojsonSource;
|
||||
this.geojsonZoomLevel = params.geojsonSourceLevel;
|
||||
this.isOsmCacheLayer = params.isOsmCache ?? false;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue