chore: automated housekeeping...

This commit is contained in:
Pieter Vander Vennet 2024-10-19 14:44:55 +02:00
parent c9ce29f206
commit 40e894df8b
294 changed files with 14209 additions and 4192 deletions

View file

@ -25,7 +25,6 @@
import { BBox } from "../../Logic/BBox"
import PanoramaxLink from "../BigComponents/PanoramaxLink.svelte"
export let tags: UIEventSource<OsmTags>
export let state: SpecialVisualizationState
export let lon: number
@ -38,7 +37,7 @@
let imagesProvider = state.nearbyImageSearcher
let loadedImages = AllImageProviders.LoadImagesFor(tags).mapD(
(loaded) => new Set(loaded.map((img) => img.url)),
(loaded) => new Set(loaded.map((img) => img.url))
)
let imageState = imagesProvider.getImagesAround(lon, lat)
let result: Store<P4CPicture[]> = imageState.images.mapD(
@ -47,53 +46,61 @@
.filter(
(p: P4CPicture) =>
!loadedImages.data.has(p.pictureUrl) && // We don't show any image which is already linked
!p.details.isSpherical,
!p.details.isSpherical
)
.slice(0, 25),
[loadedImages],
[loadedImages]
)
let asFeatures = result.map(p4cs => p4cs.map(p4c => (<Feature<Point>>{
type: "Feature",
geometry: {
type: "Point",
coordinates: [p4c.coordinates.lng, p4c.coordinates.lat],
},
properties: {
id: p4c.pictureUrl,
rotation: p4c.direction,
},
})))
let asFeatures = result.map((p4cs) =>
p4cs.map(
(p4c) =>
<Feature<Point>>{
type: "Feature",
geometry: {
type: "Point",
coordinates: [p4c.coordinates.lng, p4c.coordinates.lat],
},
properties: {
id: p4c.pictureUrl,
rotation: p4c.direction,
},
}
)
)
let selected = new UIEventSource<P4CPicture>(undefined)
let selectedAsFeature = selected.mapD(s => {
return [<Feature<Point>>{
type: "Feature",
geometry: {
type: "Point",
coordinates: [s.coordinates.lng, s.coordinates.lat],
let selectedAsFeature = selected.mapD((s) => {
return [
<Feature<Point>>{
type: "Feature",
geometry: {
type: "Point",
coordinates: [s.coordinates.lng, s.coordinates.lat],
},
properties: {
id: s.pictureUrl,
selected: "yes",
rotation: s.direction,
},
},
properties: {
id: s.pictureUrl,
selected: "yes",
rotation: s.direction,
},
}]
]
})
let someLoading = imageState.state.mapD((stateRecord) =>
Object.values(stateRecord).some((v) => v === "loading"),
Object.values(stateRecord).some((v) => v === "loading")
)
let errors = imageState.state.mapD((stateRecord) =>
Object.keys(stateRecord).filter((k) => stateRecord[k] === "error"),
Object.keys(stateRecord).filter((k) => stateRecord[k] === "error")
)
let highlighted = new UIEventSource<string>(undefined)
onDestroy(highlighted.addCallbackD(hl => {
const p4c = result.data?.find(i => i.pictureUrl === hl)
onDestroy(
highlighted.addCallbackD((hl) => {
const p4c = result.data?.find((i) => i.pictureUrl === hl)
selected.set(p4c)
},
))
})
)
let map: UIEventSource<MlMap> = new UIEventSource<MlMap>(undefined)
let mapProperties = new MapLibreAdaptor(map, {
@ -104,7 +111,6 @@
location: new UIEventSource({ lon, lat }),
})
const geocodedImageLayer = new LayerConfig(<LayerConfigJson>geocoded_image)
new ShowDataLayer(map, {
features: new StaticFeatureSource(asFeatures),
@ -115,15 +121,10 @@
},
})
ShowDataLayer.showMultipleLayers(
map,
new StaticFeatureSource([feature]),
state.theme.layers,
)
ShowDataLayer.showMultipleLayers(map, new StaticFeatureSource([feature]), state.theme.layers)
onDestroy(
asFeatures.addCallbackAndRunD(features => {
asFeatures.addCallbackAndRunD((features) => {
if (features.length == 0) {
return
}
@ -132,7 +133,7 @@
bbox = bbox.unionWith(BBox.get(f))
}
mapProperties.maxbounds.set(bbox.pad(4))
}),
})
)
new ShowDataLayer(map, {
@ -142,8 +143,6 @@
highlighted.set(feature.properties.id)
},
})
</script>
<div class="flex flex-col">
@ -158,16 +157,23 @@
{:else}
<div class="flex w-full space-x-4 overflow-x-auto" style="scroll-snap-type: x proximity">
{#each $result as image (image.pictureUrl)}
<span class="w-fit shrink-0" style="scroll-snap-align: start"
on:mouseenter={() => {highlighted.set(image.pictureUrl)}}
on:mouseleave={() =>{ highlighted.set(undefined); selected.set(undefined)}}
<span
class="w-fit shrink-0"
style="scroll-snap-align: start"
on:mouseenter={() => {
highlighted.set(image.pictureUrl)
}}
on:mouseleave={() => {
highlighted.set(undefined)
selected.set(undefined)
}}
>
<LinkableImage {tags} {image} {state} {feature} {layer} {linkable} {highlighted} />
</span>
{/each}
</div>
{/if}
<div class="w-full flex flex-wrap justify-end gap-x-8 pt-2">
<div class="flex w-full flex-wrap justify-end gap-x-8 pt-2">
<PanoramaxLink
large={false}
mapProperties={{ zoom: new ImmutableStore(16), location: new ImmutableStore({ lon, lat }) }}
@ -178,7 +184,6 @@
/>
</div>
<div class="my-2 flex justify-between">
<div>
{#if $someLoading && $result.length > 0}
@ -193,7 +198,6 @@
</div>
</div>
<div class="h-48">
<MaplibreMap interactive={false} {map} {mapProperties} />
</div>