2023-11-30 00:39:55 +01:00
|
|
|
<script lang="ts">
|
|
|
|
|
2023-12-02 03:19:50 +01:00
|
|
|
import type { SpecialVisualizationState } from "../SpecialVisualization";
|
|
|
|
import TagRenderingAnswer from "../Popup/TagRendering/TagRenderingAnswer.svelte";
|
|
|
|
import type { Feature } from "geojson";
|
|
|
|
import { ImmutableStore } from "../../Logic/UIEventSource";
|
|
|
|
import { GeoOperations } from "../../Logic/GeoOperations";
|
|
|
|
import Center from "../../assets/svg/Center.svelte";
|
|
|
|
|
|
|
|
export let feature: Feature;
|
|
|
|
let properties: Record<string, string> = feature.properties;
|
|
|
|
export let state: SpecialVisualizationState;
|
|
|
|
let tags = state.featureProperties.getStore(properties.id) ?? new ImmutableStore(properties);
|
|
|
|
|
|
|
|
const favLayer = state.layerState.filteredLayers.get("favourite");
|
2023-12-06 03:07:36 +01:00
|
|
|
const favConfig = favLayer?.layerDef;
|
|
|
|
const titleConfig = favConfig?.title;
|
2023-12-04 03:32:25 +01:00
|
|
|
|
|
|
|
function center() {
|
|
|
|
const [lon, lat] = GeoOperations.centerpointCoordinates(feature);
|
2023-12-02 03:19:50 +01:00
|
|
|
state.mapProperties.location.setData(
|
2023-12-04 03:32:25 +01:00
|
|
|
{ lon, lat }
|
|
|
|
);
|
2023-12-04 16:09:30 +01:00
|
|
|
const z = state.mapProperties.zoom.data
|
|
|
|
state.mapProperties.zoom.setData( Math.min(17, Math.max(12, z )) )
|
2023-12-04 03:32:25 +01:00
|
|
|
state.guistate.menuIsOpened.setData(false);
|
2023-12-02 03:19:50 +01:00
|
|
|
}
|
2023-12-04 03:32:25 +01:00
|
|
|
|
|
|
|
function select() {
|
|
|
|
state.selectedElement.setData(feature);
|
|
|
|
center();
|
2023-12-02 03:19:50 +01:00
|
|
|
}
|
2023-12-04 03:32:25 +01:00
|
|
|
|
|
|
|
const coord = GeoOperations.centerpointCoordinates(feature);
|
|
|
|
const distance = state.mapProperties.location.stabilized(500).mapD(({ lon, lat }) => {
|
|
|
|
let meters = Math.round(GeoOperations.distanceBetween(coord, [lon, lat]));
|
|
|
|
|
|
|
|
if (meters < 1000) {
|
|
|
|
return meters + "m";
|
2023-12-03 04:20:56 +01:00
|
|
|
}
|
2023-12-04 03:32:25 +01:00
|
|
|
|
|
|
|
meters = Math.round(meters / 100);
|
|
|
|
const kmStr = "" + meters;
|
|
|
|
|
|
|
|
|
|
|
|
return kmStr.substring(0, kmStr.length - 1) + "." + kmStr.substring(kmStr.length - 1) + "km";
|
|
|
|
});
|
|
|
|
const titleIconBlacklist = ["osmlink", "sharelink", "favourite_title_icon"];
|
2023-12-02 03:19:50 +01:00
|
|
|
|
2023-11-30 00:39:55 +01:00
|
|
|
</script>
|
|
|
|
|
2023-12-06 03:07:36 +01:00
|
|
|
{#if favLayer !== undefined}
|
2023-12-06 12:57:59 +01:00
|
|
|
<div class="px-1 my-1 border-2 border-dashed border-gray-300 rounded flex justify-between flex-wrap grid-cols-2 items-center no-weblate">
|
2023-12-04 03:32:25 +01:00
|
|
|
<button class="cursor-pointer ml-1 m-0 link justify-self-start" on:click={() => select()}>
|
|
|
|
<TagRenderingAnswer config={titleConfig} extraClasses="underline" layer={favConfig} selectedElement={feature}
|
|
|
|
{tags} />
|
2023-12-03 20:03:47 +01:00
|
|
|
</button>
|
2023-12-02 03:19:50 +01:00
|
|
|
|
2023-12-04 03:32:25 +01:00
|
|
|
|
2023-12-03 20:03:47 +01:00
|
|
|
<div class="flex items-center justify-self-end title-icons links-as-button gap-x-0.5 p-1 pt-0.5 sm:pt-1">
|
2023-12-02 03:19:50 +01:00
|
|
|
{#each favConfig.titleIcons as titleIconConfig}
|
2023-12-04 03:32:25 +01:00
|
|
|
{#if (titleIconBlacklist.indexOf(titleIconConfig.id) < 0) && (titleIconConfig.condition?.matchesProperties(properties) ?? true) && (titleIconConfig.metacondition?.matchesProperties({ ...properties, ...state.userRelatedState.preferencesAsTags.data }) ?? true) && titleIconConfig.IsKnown(properties)}
|
2023-12-02 03:19:50 +01:00
|
|
|
<div class={titleIconConfig.renderIconClass ?? "flex h-8 w-8 items-center"}>
|
|
|
|
<TagRenderingAnswer
|
|
|
|
config={titleIconConfig}
|
|
|
|
{tags}
|
|
|
|
selectedElement={feature}
|
|
|
|
{state}
|
|
|
|
layer={favLayer}
|
|
|
|
extraClasses="h-full justify-center"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
{/each}
|
2023-12-04 03:32:25 +01:00
|
|
|
|
|
|
|
<button class="p-1" on:click={() => center()}>
|
|
|
|
<Center class="w-6 h-6" />
|
|
|
|
</button>
|
|
|
|
<div class="w-14">
|
|
|
|
{$distance}
|
|
|
|
</div>
|
2023-12-02 03:19:50 +01:00
|
|
|
</div>
|
2023-11-30 00:39:55 +01:00
|
|
|
</div>
|
2023-12-06 03:07:36 +01:00
|
|
|
{/if}
|