Feature: add SVG for 3D-printing

This commit is contained in:
Pieter Vander Vennet 2023-11-06 12:44:58 +01:00
parent 8685ec8ccc
commit 8a9650c737
4 changed files with 69 additions and 15 deletions

View file

@ -5,6 +5,7 @@ import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
import { Utils } from "../../Utils"
import SimpleMetaTagger from "../../Logic/SimpleMetaTagger"
import geojson2svg from "geojson2svg"
import { GeoOperations } from "../../Logic/GeoOperations"
/**
* Exposes the download-functionality
@ -82,6 +83,7 @@ export default class DownloadHelper {
height?: 1000 | number
mapExtent?: BBox
unit?: "px" | "mm" | string
noSelfIntersectingLines?: boolean
}) {
const perLayer = this._state.perLayer
options = options ?? {}
@ -103,7 +105,7 @@ export default class DownloadHelper {
const elements: string[] = []
for (const layer of Array.from(perLayer.keys())) {
const features = perLayer.get(layer).features.data
let features = perLayer.get(layer).features.data
if (features.length === 0) {
continue
}
@ -128,7 +130,9 @@ export default class DownloadHelper {
},
],
})
if (options.noSelfIntersectingLines) {
features = GeoOperations.SplitSelfIntersectingWays(features)
}
for (const feature of features) {
const stroke =
rendering?.color?.GetRenderValue(feature.properties)?.txt ?? "#ff0000"

View file

@ -19,7 +19,7 @@
let metaIsIncluded = false
const name = state.layout.id
function offerSvg(): string {
function offerSvg(noSelfIntersectingLines: boolean): string {
const maindiv = document.getElementById("maindiv")
const layers = state.layout.layers.filter((l) => l.source !== null)
return downloadHelper.asSvg({
@ -27,6 +27,7 @@
mapExtent: state.mapProperties.bounds.data,
width: maindiv.offsetWidth,
height: maindiv.offsetHeight,
noSelfIntersectingLines: true
})
}
</script>
@ -71,9 +72,19 @@
mimetype="image/svg+xml"
mainText={t.downloadAsSvg}
helperText={t.downloadAsSvgHelper}
construct={offerSvg}
construct={() => offerSvg(false)}
/>
<DownloadButton
{state}
{metaIsIncluded}
extension="svg"
mimetype="image/svg+xml"
mainText={t.downloadAsSvgLinesOnly}
helperText={t.downloadAsSvgLinesOnlyHelper}
construct={() => offerSvg(true)}
/>
<DownloadButton
{state}
{metaIsIncluded}