Chore: small linting issues and formatting

This commit is contained in:
Pieter Vander Vennet 2025-02-22 23:42:06 +01:00
parent b606fa57a8
commit 6a9677fc78
4 changed files with 16 additions and 31 deletions

View file

@ -68,8 +68,7 @@
"type": "fill",
"source": "protomaps",
"source-layer": "landuse",
"filter": [
"any",
"filter":
[
"in",
"kind",
@ -78,7 +77,6 @@
"cemetery",
"nature_reserve",
"golf_course"
]
],
"paint": {
"fill-color": [

View file

@ -1,17 +1,11 @@
import { ImmutableStore, Store, UIEventSource } from "../../Logic/UIEventSource"
import maplibregl, {
Map as MLMap,
Map as MlMap,
ScaleControl,
SourceSpecification,
} from "maplibre-gl"
import maplibregl, { Map as MLMap, Map as MlMap, ScaleControl } from "maplibre-gl"
import { RasterLayerPolygon } from "../../Models/RasterLayers"
import { Utils } from "../../Utils"
import { BBox } from "../../Logic/BBox"
import { ExportableMap, KeyNavigationEvent, MapProperties } from "../../Models/MapProperties"
import SvelteUIElement from "../Base/SvelteUIElement"
import MaplibreMap from "./MaplibreMap.svelte"
import { RasterLayerProperties } from "../../Models/RasterLayerProperties"
import * as htmltoimage from "html-to-image"
import RasterLayerHandler from "./RasterLayerHandler"
import Constants from "../../Models/Constants"
@ -125,7 +119,6 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap {
nearestFeature?: Feature
}>(undefined)
this.lastClickLocation = lastClickLocation
const self = this
new RasterLayerHandler(this._maplibreMap, this.rasterLayer)
@ -294,10 +287,6 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap {
}
}
public static prepareWmsSource(layer: RasterLayerProperties): SourceSpecification {
return RasterLayerHandler.prepareSource(layer)
}
/**
* Prepares an ELI-URL to be compatible with mapbox
*/

View file

@ -1,4 +1,4 @@
import { Map as MLMap, RasterSourceSpecification, VectorTileSource } from "maplibre-gl"
import { Map as MLMap, RasterSourceSpecification } from "maplibre-gl"
import { Store, Stores, UIEventSource } from "../../Logic/UIEventSource"
import { RasterLayerPolygon } from "../../Models/RasterLayers"
import { RasterLayerProperties } from "../../Models/RasterLayerProperties"
@ -144,8 +144,8 @@ class SingleBackgroundHandler {
type: "raster",
source: background.id,
paint: {
"raster-opacity": 0,
},
"raster-opacity": 0
}
},
addLayerBeforeId
)
@ -166,14 +166,14 @@ class SingleBackgroundHandler {
Stores.Chronic(
8,
() => this.opacity.data > 0 && this._deactivationTime !== undefined
).addCallback((_) => this.opacity.setData(Math.max(0, this.opacity.data - this.fadeStep)))
).addCallback(() => this.opacity.setData(Math.max(0, this.opacity.data - this.fadeStep)))
}
private fadeIn() {
Stores.Chronic(
8,
() => this.opacity.data < 1.0 && this._deactivationTime === undefined
).addCallback((_) => this.opacity.setData(Math.min(1.0, this.opacity.data + this.fadeStep)))
).addCallback(() => this.opacity.setData(Math.min(1.0, this.opacity.data + this.fadeStep)))
}
}
@ -193,11 +193,10 @@ export default class RasterLayerHandler {
layer: RasterLayerProperties
): RasterSourceSpecification | VectorSourceSpecification {
if (layer.type === "vector") {
const vs: VectorSourceSpecification = {
return {
type: "vector",
url: layer.url,
url: layer.url
}
return vs
}
return {
type: "raster",
@ -208,7 +207,7 @@ export default class RasterLayerHandler {
minzoom: layer["min_zoom"] ?? 1,
maxzoom: layer["max_zoom"] ?? 25,
// Bit of a hack, but seems to work
scheme: layer.url.includes("{-y}") ? "tms" : "xyz",
scheme: layer.url.includes("{-y}") ? "tms" : "xyz"
}
}
@ -222,7 +221,7 @@ export default class RasterLayerHandler {
"{width}": "" + size,
"{height}": "" + size,
"{zoom}": "{z}",
"{-y}": "{y}",
"{-y}": "{y}"
}
for (const key in toReplace) {

View file

@ -1,8 +1,8 @@
import { Store, UIEventSource } from "../../Logic/UIEventSource"
import { Map as MlMap } from "maplibre-gl"
import { Utils } from "../../Utils"
import { MapLibreAdaptor } from "./MapLibreAdaptor"
import { RasterLayerProperties } from "../../Models/RasterLayerProperties"
import RasterLayerHandler from "./RasterLayerHandler"
export default class ShowOverlayRasterLayer {
private readonly _map: UIEventSource<MlMap>
@ -42,9 +42,9 @@ export default class ShowOverlayRasterLayer {
}
private setVisibility() {
let zoom = this._mapProperties?.zoom?.data
let withinRange = zoom === undefined || zoom > this._layer.min_zoom
let isDisplayed = (this._isDisplayed?.data ?? true) && withinRange
const zoom = this._mapProperties?.zoom?.data
const withinRange = zoom === undefined || zoom > this._layer.min_zoom
const isDisplayed = (this._isDisplayed?.data ?? true) && withinRange
try {
this._map.data?.setLayoutProperty(
this._layer.id,
@ -78,8 +78,7 @@ export default class ShowOverlayRasterLayer {
return
}
const background: RasterLayerProperties = this._layer
map.addSource(background.id, MapLibreAdaptor.prepareWmsSource(background))
map.addSource(background.id, RasterLayerHandler.prepareSource(background))
this._mllayer = map.addLayer({
id: background.id,
type: "raster",