2023-11-16 03:32:04 +01:00
|
|
|
<script lang="ts">
|
2023-11-23 15:47:16 +01:00
|
|
|
import type { Feature } from "geojson"
|
|
|
|
import type { SpecialVisualizationState } from "../SpecialVisualization"
|
|
|
|
import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
|
|
|
|
import TagRenderingAnswer from "../Popup/TagRendering/TagRenderingAnswer.svelte"
|
2023-12-16 01:29:42 +01:00
|
|
|
import { GeoOperations } from "../../Logic/GeoOperations"
|
|
|
|
import { Store } from "../../Logic/UIEventSource"
|
2023-11-16 03:32:04 +01:00
|
|
|
|
2023-11-23 15:47:16 +01:00
|
|
|
export let state: SpecialVisualizationState
|
2023-11-16 03:32:04 +01:00
|
|
|
export let feature: Feature
|
2023-12-15 01:46:01 +01:00
|
|
|
export let i: number = undefined
|
2023-11-16 03:32:04 +01:00
|
|
|
let id = feature.properties.id
|
2023-11-23 15:47:16 +01:00
|
|
|
let tags = state.featureProperties.getStore(id)
|
2023-11-16 03:32:04 +01:00
|
|
|
let layer: LayerConfig = state.layout.getMatchingLayer(tags.data)
|
2023-12-15 01:46:01 +01:00
|
|
|
|
|
|
|
function select() {
|
2023-12-06 03:07:15 +01:00
|
|
|
state.selectedElement.setData(undefined)
|
|
|
|
state.selectedLayer.setData(layer)
|
|
|
|
state.selectedElement.setData(feature)
|
|
|
|
}
|
2023-12-16 01:29:42 +01:00
|
|
|
|
|
|
|
let bearingAndDist: Store<{ bearing: number, dist: number }> = state.mapProperties.location.map(l => {
|
|
|
|
let fcenter = GeoOperations.centerpointCoordinates(feature)
|
|
|
|
let mapCenter = [l.lon, l.lat]
|
|
|
|
|
|
|
|
let bearing = Math.round(GeoOperations.bearing(fcenter, mapCenter))
|
|
|
|
let dist = Math.round(GeoOperations.distanceBetween(fcenter, mapCenter))
|
|
|
|
return { bearing, dist }
|
|
|
|
},
|
|
|
|
)
|
2023-11-16 03:32:04 +01:00
|
|
|
</script>
|
|
|
|
|
2023-12-16 01:29:42 +01:00
|
|
|
<button class="cursor-pointer small flex" on:click={() => select()}>
|
2023-12-15 01:46:01 +01:00
|
|
|
{#if i !== undefined}
|
|
|
|
<span class="font-bold">{i + 1}.</span>
|
|
|
|
{/if}
|
|
|
|
<TagRenderingAnswer config={layer.title} {layer} selectedElement={feature} {state} {tags} />
|
2023-12-16 01:29:42 +01:00
|
|
|
<span class="flex">{$bearingAndDist.dist}m {$bearingAndDist.bearing}°</span>
|
2023-12-15 01:46:01 +01:00
|
|
|
</button>
|