Chore: housekeeping

This commit is contained in:
Pieter Vander Vennet 2025-02-10 02:04:58 +01:00
parent cd9e03dd6f
commit b300fffdc5
156 changed files with 4436 additions and 1318 deletions

View file

@ -27,7 +27,7 @@
{#if marker}
<div class="relative h-full w-full" style={`transform: rotate(${$_rotation})`}>
{#each marker as icon}
<div class="absolute top-0 left-0 h-full w-full">
<div class="absolute left-0 top-0 h-full w-full">
<DynamicIcon {icon} {tags} {emojiHeight} />
</div>
{/each}

View file

@ -1,5 +1,10 @@
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,
SourceSpecification,
} from "maplibre-gl"
import { RasterLayerPolygon } from "../../Models/RasterLayers"
import { Utils } from "../../Utils"
import { BBox } from "../../Logic/BBox"
@ -25,13 +30,13 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap {
"dragRotate",
"dragPan",
"keyboard",
"touchZoomRotate"
"touchZoomRotate",
]
private static maplibre_zoom_handlers = [
"scrollZoom",
"boxZoom",
"doubleClickZoom",
"touchZoomRotate"
"touchZoomRotate",
]
readonly location: UIEventSource<{ lon: number; lat: number }>
private readonly isFlying = new UIEventSource(false)
@ -45,14 +50,14 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap {
readonly lastClickLocation: Store<
| undefined
| {
lon: number
lat: number
mode: "left" | "right" | "middle"
/**
* The nearest feature from a MapComplete layer
*/
nearestFeature?: Feature
}
lon: number
lat: number
mode: "left" | "right" | "middle"
/**
* The nearest feature from a MapComplete layer
*/
nearestFeature?: Feature
}
>
readonly minzoom: UIEventSource<number>
readonly maxzoom: UIEventSource<number>
@ -143,7 +148,7 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap {
const features = map
.queryRenderedFeatures([
[point.x - buffer, point.y - buffer],
[point.x + buffer, point.y + buffer]
[point.x + buffer, point.y + buffer],
])
.filter((f) => f.source.startsWith("mapcomplete_"))
if (features.length === 1) {
@ -283,9 +288,9 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap {
return {
map: mlmap,
ui: new SvelteUIElement(MaplibreMap, {
map: mlmap
map: mlmap,
}),
mapproperties: new MapLibreAdaptor(mlmap)
mapproperties: new MapLibreAdaptor(mlmap),
}
}
@ -353,7 +358,7 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap {
) {
const event = {
date: new Date(),
key: key
key: key,
}
for (let i = 0; i < this._onKeyNavigation.length; i++) {
@ -542,7 +547,7 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap {
const bounds = map.getBounds()
const bbox = new BBox([
[bounds.getEast(), bounds.getNorth()],
[bounds.getWest(), bounds.getSouth()]
[bounds.getWest(), bounds.getSouth()],
])
if (this.bounds.data === undefined || !isSetup) {
this.bounds.setData(bbox)
@ -736,14 +741,14 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap {
type: "raster-dem",
url:
"https://api.maptiler.com/tiles/terrain-rgb/tiles.json?key=" +
Constants.maptilerApiKey
Constants.maptilerApiKey,
})
try {
while (!map?.isStyleLoaded()) {
await Utils.waitFor(250)
}
map.setTerrain({
source: id
source: id,
})
} catch (e) {
console.error(e)
@ -768,7 +773,7 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap {
if (this.scaleControl === undefined) {
this.scaleControl = new ScaleControl({
maxWidth: 100,
unit: "metric"
unit: "metric",
})
}
if (!map.hasControl(this.scaleControl)) {
@ -781,7 +786,7 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap {
window.requestAnimationFrame(() => {
this._maplibreMap.data?.flyTo({
zoom,
center: [lon, lat]
center: [lon, lat],
})
})
}

View file

@ -112,4 +112,4 @@
<link href="./maplibre-gl.css" rel="stylesheet" />
</svelte:head>
<div bind:this={container} class="map relative top-0 left-0 h-full w-full" id="map" />
<div bind:this={container} class="map relative left-0 top-0 h-full w-full" id="map" />

View file

@ -41,7 +41,7 @@
{#if iconsParsed !== undefined && iconsParsed.length > 0}
<div class={twMerge("relative", size)}>
{#each iconsParsed as icon}
<div class="absolute top-0 left-0 flex h-full w-full items-center">
<div class="absolute left-0 top-0 flex h-full w-full items-center">
<Icon icon={icon.icon} color={icon.color} {clss} {emojiHeight} />
</div>
{/each}

View file

@ -122,10 +122,7 @@ class PointRenderingLayer {
continue
}
const loc = GeoOperations.featureToCoordinateWithRenderingType(
feature,
location
)
const loc = GeoOperations.featureToCoordinateWithRenderingType(feature, location)
if (loc === undefined) {
continue
}
@ -199,10 +196,14 @@ class PointRenderingLayer {
.addTo(this._map)
store
.map((tags) => this._config.pitchAlignment.GetRenderValue(tags).Subs(tags).txt)
.addCallbackAndRun((pitchAligment) => marker.setPitchAlignment(<Alignment>pitchAligment))
.addCallbackAndRun((pitchAligment) =>
marker.setPitchAlignment(<Alignment>pitchAligment)
)
store
.map((tags) => this._config.rotationAlignment.GetRenderValue(tags).Subs(tags).txt)
.addCallbackAndRun((pitchAligment) => marker.setRotationAlignment(<Alignment>pitchAligment))
.addCallbackAndRun((pitchAligment) =>
marker.setRotationAlignment(<Alignment>pitchAligment)
)
if (feature.geometry.type === "Point") {
// When the tags get 'pinged', check that the location didn't change
@ -507,7 +508,10 @@ class LineRenderingLayer {
}
export default class ShowDataLayer {
public static rangeLayer = new LayerConfig(<LayerConfigJson>range_layer, "ShowDataLayer.ts:range.json")
public static rangeLayer = new LayerConfig(
<LayerConfigJson>range_layer,
"ShowDataLayer.ts:range.json"
)
private readonly _options: ShowDataLayerOptions & {
layer: LayerConfig
drawMarkers?: true | boolean