2023-06-04 00:43:32 +02:00
|
|
|
<script lang="ts">
|
2023-06-14 20:39:36 +02:00
|
|
|
import Loading from "../Base/Loading.svelte"
|
|
|
|
import Translations from "../i18n/Translations"
|
|
|
|
import Tr from "../Base/Tr.svelte"
|
|
|
|
import DownloadHelper from "./DownloadHelper"
|
|
|
|
import DownloadButton from "./DownloadButton.svelte"
|
|
|
|
import { GeoOperations } from "../../Logic/GeoOperations"
|
|
|
|
import { SvgToPdf } from "../../Utils/svgToPdf"
|
|
|
|
import ThemeViewState from "../../Models/ThemeViewState"
|
|
|
|
import DownloadPdf from "./DownloadPdf.svelte"
|
2024-04-01 01:39:04 +02:00
|
|
|
import { PngMapCreator } from "../../Utils/pngMapCreator"
|
|
|
|
import { UIEventSource } from "../../Logic/UIEventSource"
|
|
|
|
import ValidatedInput from "../InputElement/ValidatedInput.svelte"
|
|
|
|
import { LocalStorageSource } from "../../Logic/Web/LocalStorageSource"
|
2023-06-14 20:39:36 +02:00
|
|
|
|
|
|
|
export let state: ThemeViewState
|
|
|
|
let isLoading = state.dataIsLoading
|
|
|
|
|
|
|
|
const t = Translations.t.general.download
|
|
|
|
|
|
|
|
const downloadHelper = new DownloadHelper(state)
|
|
|
|
|
|
|
|
let metaIsIncluded = false
|
|
|
|
|
2024-02-21 16:35:49 +01:00
|
|
|
let numberOfFeatures = state.featureSummary.totalNumberOfFeatures
|
|
|
|
|
|
|
|
async function getGeojson() {
|
|
|
|
await state.indexedFeatures.downloadAll()
|
|
|
|
return downloadHelper.getCleanGeoJson(metaIsIncluded)
|
|
|
|
}
|
|
|
|
|
|
|
|
async function offerSvg(noSelfIntersectingLines: boolean): Promise<string> {
|
|
|
|
await state.indexedFeatures.downloadAll()
|
2023-06-14 20:39:36 +02:00
|
|
|
const maindiv = document.getElementById("maindiv")
|
|
|
|
const layers = state.layout.layers.filter((l) => l.source !== null)
|
|
|
|
return downloadHelper.asSvg({
|
|
|
|
layers,
|
|
|
|
mapExtent: state.mapProperties.bounds.data,
|
|
|
|
width: maindiv.offsetWidth,
|
|
|
|
height: maindiv.offsetHeight,
|
2024-04-13 02:40:21 +02:00
|
|
|
noSelfIntersectingLines,
|
2023-06-14 20:39:36 +02:00
|
|
|
})
|
|
|
|
}
|
2024-04-01 01:39:04 +02:00
|
|
|
|
|
|
|
let customWidth = LocalStorageSource.Get("custom-png-width", "20")
|
|
|
|
let customHeight = LocalStorageSource.Get("custom-png-height", "20")
|
|
|
|
|
|
|
|
async function offerCustomPng(): Promise<Blob> {
|
2024-04-13 02:40:21 +02:00
|
|
|
console.log(
|
|
|
|
"Creating a custom size png with dimensions",
|
|
|
|
customWidth.data + "mm *",
|
|
|
|
customHeight.data + "mm"
|
|
|
|
)
|
2024-04-01 01:39:04 +02:00
|
|
|
const creator = new PngMapCreator(state, {
|
2024-04-13 02:40:21 +02:00
|
|
|
height: Number(customHeight.data),
|
|
|
|
width: Number(customWidth.data),
|
2024-04-01 01:39:04 +02:00
|
|
|
})
|
|
|
|
return await creator.CreatePng("belowmap")
|
|
|
|
}
|
2023-06-04 00:43:32 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
{#if $isLoading}
|
2023-06-14 20:39:36 +02:00
|
|
|
<Loading />
|
2024-02-21 16:35:49 +01:00
|
|
|
{:else if $numberOfFeatures > 100000}
|
|
|
|
<Tr cls="alert" t={Translations.t.general.download.toMuch} />
|
2023-06-04 00:43:32 +02:00
|
|
|
{:else}
|
2023-06-14 20:44:01 +02:00
|
|
|
<div class="flex w-full flex-col" />
|
2023-06-14 20:39:36 +02:00
|
|
|
<h3>
|
|
|
|
<Tr t={t.title} />
|
|
|
|
</h3>
|
|
|
|
|
|
|
|
<DownloadButton
|
|
|
|
{state}
|
|
|
|
extension="geojson"
|
|
|
|
mimetype="application/vnd.geo+json"
|
2024-02-21 16:35:49 +01:00
|
|
|
construct={async () => JSON.stringify(await getGeojson())}
|
2023-06-14 20:39:36 +02:00
|
|
|
mainText={t.downloadGeojson}
|
|
|
|
helperText={t.downloadGeoJsonHelper}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<DownloadButton
|
|
|
|
{state}
|
|
|
|
extension="csv"
|
|
|
|
mimetype="text/csv"
|
2024-02-21 16:35:49 +01:00
|
|
|
construct={async () => GeoOperations.toCSV(await getGeojson())}
|
2023-06-14 20:39:36 +02:00
|
|
|
mainText={t.downloadCSV}
|
|
|
|
helperText={t.downloadCSVHelper}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<label class="mb-8 mt-2">
|
|
|
|
<input type="checkbox" bind:value={metaIsIncluded} />
|
|
|
|
<Tr t={t.includeMetaData} />
|
|
|
|
</label>
|
|
|
|
|
|
|
|
<DownloadButton
|
|
|
|
{state}
|
|
|
|
extension="svg"
|
|
|
|
mimetype="image/svg+xml"
|
|
|
|
mainText={t.downloadAsSvg}
|
|
|
|
helperText={t.downloadAsSvgHelper}
|
2023-11-06 12:44:58 +01:00
|
|
|
construct={() => offerSvg(false)}
|
2023-06-14 20:39:36 +02:00
|
|
|
/>
|
|
|
|
|
2023-11-06 12:44:58 +01:00
|
|
|
<DownloadButton
|
|
|
|
{state}
|
|
|
|
extension="svg"
|
|
|
|
mimetype="image/svg+xml"
|
|
|
|
mainText={t.downloadAsSvgLinesOnly}
|
|
|
|
helperText={t.downloadAsSvgLinesOnlyHelper}
|
|
|
|
construct={() => offerSvg(true)}
|
|
|
|
/>
|
2023-11-09 16:30:26 +01:00
|
|
|
|
2023-06-14 20:39:36 +02:00
|
|
|
<DownloadButton
|
|
|
|
{state}
|
|
|
|
extension="png"
|
|
|
|
mimetype="image/png"
|
|
|
|
mainText={t.downloadAsPng}
|
|
|
|
helperText={t.downloadAsPngHelper}
|
2023-11-14 16:14:27 +01:00
|
|
|
construct={() => state.mapProperties.exportAsPng()}
|
2023-06-14 20:39:36 +02:00
|
|
|
/>
|
|
|
|
|
|
|
|
<div class="flex flex-col">
|
|
|
|
{#each Object.keys(SvgToPdf.templates) as key}
|
|
|
|
{#if SvgToPdf.templates[key].isPublic}
|
|
|
|
<DownloadPdf {state} templateName={key} />
|
|
|
|
{/if}
|
|
|
|
{/each}
|
|
|
|
</div>
|
|
|
|
|
2024-04-13 02:40:21 +02:00
|
|
|
<div class="low-interaction mt-4 p-2">
|
2024-04-01 01:39:04 +02:00
|
|
|
<h3 class="m-0 mb-2">
|
2024-04-13 02:40:21 +02:00
|
|
|
<Tr t={t.custom.title} />
|
|
|
|
</h3>
|
|
|
|
<div class="flex">
|
|
|
|
<Tr t={t.custom.width} />
|
|
|
|
<ValidatedInput {state} type="pnat" value={customWidth} />
|
|
|
|
</div>
|
|
|
|
<div class="flex">
|
|
|
|
<Tr t={t.custom.height} />
|
|
|
|
<ValidatedInput {state} type="pnat" value={customHeight} />
|
|
|
|
</div>
|
|
|
|
<DownloadButton
|
|
|
|
mainText={t.custom.download.Subs({ width: $customWidth, height: $customHeight })}
|
|
|
|
helperText={t.custom.downloadHelper}
|
|
|
|
extension="png"
|
|
|
|
construct={() => offerCustomPng()}
|
|
|
|
{state}
|
|
|
|
mimetype="image/png"
|
|
|
|
/>
|
2024-04-01 01:39:04 +02:00
|
|
|
</div>
|
|
|
|
|
2023-06-14 20:39:36 +02:00
|
|
|
<Tr cls="link-underline" t={t.licenseInfo} />
|
2023-06-04 00:43:32 +02:00
|
|
|
{/if}
|