refactoring: more state splitting, basic layoutFeatureSource

This commit is contained in:
Pieter Vander Vennet 2023-03-26 05:58:28 +02:00
parent 8e2f04c0d0
commit b94a8f5745
54 changed files with 1067 additions and 1969 deletions

View file

@ -94,7 +94,6 @@ export default class DependencyCalculator {
return []
},
memberships: undefined,
}
// Init the extra patched functions...
ExtraFunctions.FullPatchFeature(params, obj)

View file

@ -42,35 +42,19 @@ export interface LayerConfigJson {
*
* Note: a source must always be defined. 'special' is only allowed if this is a builtin-layer
*/
source: "special" | "special:library" | ({
/**
* Every source must set which tags have to be present in order to load the given layer.
*/
osmTags: TagConfigJson
/**
* The maximum amount of seconds that a tile is allowed to linger in the cache
*/
maxCacheAge?: number
} & (
| {
source:
| "special"
| "special:library"
| ({
/**
* If set, this custom overpass-script will be used instead of building one by using the OSM-tags.
* Specifying OSM-tags is still obligatory and will still hide non-matching items and they will be used for the rest of the pipeline.
* _This should be really rare_.
*
* For example, when you want to fetch all grass-areas in parks and which are marked as publicly accessible:
* ```
* "source": {
* "overpassScript":
* "way[\"leisure\"=\"park\"];node(w);is_in;area._[\"leisure\"=\"park\"];(way(area)[\"landuse\"=\"grass\"]; node(w); );",
* "osmTags": "access=yes"
* }
* ```
*
* Every source must set which tags have to be present in order to load the given layer.
*/
overpassScript?: string
}
| {
osmTags: TagConfigJson
/**
* The maximum amount of seconds that a tile is allowed to linger in the cache
*/
maxCacheAge?: number
} & {
/**
* The actual source of the data to load, if loaded via geojson.
*
@ -104,7 +88,6 @@ export interface LayerConfigJson {
*/
idKey?: string
})
)
/**
*

View file

@ -68,6 +68,8 @@ export default class LayerConfig extends WithContextLoader {
public readonly forceLoad: boolean
public readonly syncSelection: typeof LayerConfig.syncSelectionAllowed[number] // this is a trick to conver a constant array of strings into a type union of these values
public readonly _needsFullNodeDatabase = false
constructor(json: LayerConfigJson, context?: string, official: boolean = true) {
context = context + "." + json.id
const translationContext = "layers:" + json.id
@ -250,7 +252,7 @@ export default class LayerConfig extends WithContextLoader {
| "osmbasedmap"
| "historicphoto"
| string
)[]
)[]
if (typeof pr.preciseInput.preferredBackground === "string") {
preferredBackground = [pr.preciseInput.preferredBackground]
} else {

View file

@ -3,7 +3,6 @@ import { RegexTag } from "../../Logic/Tags/RegexTag"
export default class SourceConfig {
public osmTags?: TagsFilter
public readonly overpassScript?: string
public geojsonSource?: string
public geojsonZoomLevel?: number
public isOsmCacheLayer: boolean
@ -68,7 +67,6 @@ export default class SourceConfig {
}
}
this.osmTags = params.osmTags ?? new RegexTag("id", /.*/)
this.overpassScript = params.overpassScript
this.geojsonSource = params.geojsonSource
this.geojsonZoomLevel = params.geojsonSourceLevel
this.isOsmCacheLayer = params.isOsmCache ?? false