chore: automated housekeeping...

This commit is contained in:
Pieter Vander Vennet 2024-11-28 12:00:23 +01:00
parent 8ef7af613f
commit 00151afdea
114 changed files with 2857 additions and 2135 deletions

View file

@ -39,7 +39,7 @@ class PointRenderingLayer {
visibility?: Store<boolean>,
fetchStore?: (id: string) => Store<Record<string, string>>,
onClick?: (feature: Feature) => void,
selectedElement?: Store<{ properties: { id?: string } }>,
selectedElement?: Store<{ properties: { id?: string } }>
) {
this._visibility = visibility
this._config = config
@ -98,7 +98,7 @@ class PointRenderingLayer {
" while rendering",
location,
"of",
this._config,
this._config
)
}
const id = feature.properties.id + "-" + location
@ -110,7 +110,10 @@ class PointRenderingLayer {
this.addPoint(feature, <[number, number]>loc)
}
}
if (feature.geometry.type === "MultiLineString" || feature.geometry.type === "Polygon") {
if (
feature.geometry.type === "MultiLineString" ||
feature.geometry.type === "Polygon"
) {
for (const coors of feature.geometry.coordinates) {
for (const loc of coors) {
this.addPoint(feature, <[number, number]>loc)
@ -122,7 +125,7 @@ class PointRenderingLayer {
const loc = GeoOperations.featureToCoordinateWithRenderingType(
<any>feature,
location,
location
)
if (loc === undefined) {
continue
@ -251,7 +254,7 @@ class LineRenderingLayer {
config: LineRenderingConfig,
visibility?: Store<boolean>,
fetchStore?: (id: string) => Store<Record<string, string>>,
onClick?: (feature: Feature) => void,
onClick?: (feature: Feature) => void
) {
this._layername = layername
this._map = map
@ -271,7 +274,7 @@ class LineRenderingLayer {
private async addSymbolLayer(
sourceId: string,
imageAlongWay: { if?: TagsFilter; then: string }[],
imageAlongWay: { if?: TagsFilter; then: string }[]
) {
const map = this._map
await Promise.allSettled(
@ -301,7 +304,7 @@ class LineRenderingLayer {
spec.filter = filter
}
map.addLayer(spec)
}),
})
)
}
@ -311,7 +314,7 @@ class LineRenderingLayer {
* @private
*/
private calculatePropsFor(
properties: Record<string, string>,
properties: Record<string, string>
): Partial<Record<(typeof LineRenderingLayer.lineConfigKeys)[number], string>> {
const config = this._config
@ -393,7 +396,7 @@ class LineRenderingLayer {
} catch (e) {
console.error(
`Invalid dasharray in layer ${this._layername}:`,
this._config.dashArray,
this._config.dashArray
)
}
}
@ -410,11 +413,11 @@ class LineRenderingLayer {
}
map.setFeatureState(
{ source: this._layername, id: feature.properties.id },
this.calculatePropsFor(feature.properties),
this.calculatePropsFor(feature.properties)
)
}
if(this._onClick){
if (this._onClick) {
map.on("click", linelayer, (e) => {
// line-layer-listener
e.originalEvent["consumed"] = true
@ -455,7 +458,7 @@ class LineRenderingLayer {
"Error while setting visibility of layers ",
linelayer,
polylayer,
e,
e
)
}
})
@ -476,7 +479,7 @@ class LineRenderingLayer {
console.trace(
"Got a feature without ID; this causes rendering bugs:",
feature,
"from",
"from"
)
LineRenderingLayer.missingIdTriggered = true
}
@ -488,7 +491,7 @@ class LineRenderingLayer {
if (this._fetchStore === undefined) {
map.setFeatureState(
{ source: this._layername, id },
this.calculatePropsFor(feature.properties),
this.calculatePropsFor(feature.properties)
)
} else {
const tags = this._fetchStore(id)
@ -505,7 +508,7 @@ class LineRenderingLayer {
}
map.setFeatureState(
{ source: this._layername, id },
this.calculatePropsFor(properties),
this.calculatePropsFor(properties)
)
})
}
@ -529,7 +532,7 @@ export default class ShowDataLayer {
layer: LayerConfig
drawMarkers?: true | boolean
drawLines?: true | boolean
},
}
) {
this._options = options
this.onDestroy.push(map.addCallbackAndRunD((map) => this.initDrawFeatures(map)))
@ -539,7 +542,7 @@ export default class ShowDataLayer {
mlmap: UIEventSource<MlMap>,
features: FeatureSource,
layers: LayerConfig[],
options?: Partial<ShowDataLayerOptions>,
options?: Partial<ShowDataLayerOptions>
) {
const perLayer: PerLayerFeatureSourceSplitter<FeatureSourceForLayer> =
new PerLayerFeatureSourceSplitter(
@ -547,7 +550,7 @@ export default class ShowDataLayer {
features,
{
constructStore: (features, layer) => new SimpleFeatureSource(layer, features),
},
}
)
if (options?.zoomToFeatures) {
options.zoomToFeatures = false
@ -571,7 +574,7 @@ export default class ShowDataLayer {
public static showRange(
map: Store<MlMap>,
features: FeatureSource,
doShowLayer?: Store<boolean>,
doShowLayer?: Store<boolean>
): ShowDataLayer {
return new ShowDataLayer(map, {
layer: ShowDataLayer.rangeLayer,
@ -580,8 +583,7 @@ export default class ShowDataLayer {
})
}
public destruct() {
}
public destruct() {}
private static zoomToCurrentFeatures(map: MlMap, features: Feature[]) {
if (!features || !map || features.length == 0) {
@ -605,8 +607,8 @@ export default class ShowDataLayer {
this._options.layer.title === undefined
? undefined
: (feature: Feature) => {
selectedElement?.setData(feature)
}
selectedElement?.setData(feature)
}
}
if (this._options.drawLines !== false) {
for (let i = 0; i < this._options.layer.lineRendering.length; i++) {
@ -618,7 +620,7 @@ export default class ShowDataLayer {
lineRenderingConfig,
doShowLayer,
fetchStore,
onClick,
onClick
)
this.onDestroy.push(l.destruct)
}
@ -634,13 +636,13 @@ export default class ShowDataLayer {
doShowLayer,
fetchStore,
onClick,
selectedElement,
selectedElement
)
}
}
if (this._options.zoomToFeatures) {
features.features.addCallbackAndRunD((features) =>
ShowDataLayer.zoomToCurrentFeatures(map, features),
ShowDataLayer.zoomToCurrentFeatures(map, features)
)
}
}