all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [PATCH datacenter-manager v2 3/4] ui: add world map geojson update script
Date: Tue,  5 May 2026 09:31:58 +0200	[thread overview]
Message-ID: <20260505073203.398548-8-d.csapak@proxmox.com> (raw)
In-Reply-To: <20260505073203.398548-1-d.csapak@proxmox.com>

the data source is natural earth[0] which is in the public domain. It's
also maintained on github[1] which is used for the update script.

include a small script to convert the shapefile to the necessary geojson
file with 'ogr2ogr' from the `gdal-bin` package.

It's not added as a dev-dependency, since it should not update often.
(last update of this data was in 2018 so ~6 years ago)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
changes from v1:
* don't include the map data itself
* use github to download the files and generate the world-map.json file

 ui/Makefile            |  6 ++++--
 ui/index.html          |  1 +
 ui/update-world-map.sh | 26 ++++++++++++++++++++++++++
 3 files changed, 31 insertions(+), 2 deletions(-)
 create mode 100755 ui/update-world-map.sh

diff --git a/ui/Makefile b/ui/Makefile
index 403f6d55..6562ae5e 100644
--- a/ui/Makefile
+++ b/ui/Makefile
@@ -51,7 +51,7 @@ dist/pdm-ui_bg.wasm.gz: dist/pdm-ui_bg.wasm
 dist/%.css: css/%.scss dist
 	rust-grass $< $@
 
-install: $(COMPILED_OUTPUT) index.hbs
+install: $(COMPILED_OUTPUT) index.hbs world-map.json
 	install -dm0755 $(DESTDIR)$(UIDIR)
 	install -dm0755 $(DESTDIR)$(UIDIR)/js
 
@@ -76,6 +76,8 @@ install: $(COMPILED_OUTPUT) index.hbs
 	install -m0644 dist/material-yew-style.css $(DESTDIR)$(UIDIR)
 	install -m0644 dist/desktop-yew-style.css $(DESTDIR)$(UIDIR)
 
+	install -m0644 world-map.json $(DESTDIR)$(UIDIR)
+
 .PHONY: submodule
 submodule:
 	test -f "pwt-assets/README.md" || git submodule update --init
@@ -83,7 +85,7 @@ submodule:
 $(BUILDDIR): submodule
 	rm -rf $@ $@.tmp
 	mkdir -p $@.tmp/ui
-	cp -a debian/ src/ pwt-assets/ images/ css/ index.hbs Makefile Cargo.toml $@.tmp/ui
+	cp -a debian/ src/ pwt-assets/ images/ css/ index.hbs world-map.json Makefile Cargo.toml $@.tmp/ui
 	cp -a ../Cargo.toml ../lib $@.tmp/
 	echo "git clone git://git.proxmox.com/git/$(PACKAGE).git\\ngit checkout $$(git rev-parse HEAD)" \
 	    > $@.tmp/ui/debian/SOURCE
diff --git a/ui/index.html b/ui/index.html
index 6b81f7d8..48256a67 100644
--- a/ui/index.html
+++ b/ui/index.html
@@ -12,6 +12,7 @@
     <link data-trunk href="pwt-assets/assets/fonts" rel="copy-dir"/>
 
     <link data-trunk href="images" rel="copy-dir"/>
+    <link data-trunk href="world-map.json" rel="copy-file"/>
 
     <style>
       /* Avoid flickering (default background in firefox is always white)*/
diff --git a/ui/update-world-map.sh b/ui/update-world-map.sh
new file mode 100755
index 00000000..a0820715
--- /dev/null
+++ b/ui/update-world-map.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# Shapefile (public domain) source is:
+#
+# https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_countries.zip
+# and
+# https://github.com/nvkelso/natural-earth-vector
+
+set -e
+
+NAME="ne_110m_admin_0_countries"
+SHP_SOURCE="https://github.com/nvkelso/natural-earth-vector/raw/refs/heads/master/110m_cultural/${NAME}.shp"
+SHX_SOURCE="https://github.com/nvkelso/natural-earth-vector/raw/refs/heads/master/110m_cultural/${NAME}.shx"
+SQL_COMMAND="SELECT 'land' AS kind, ST_Union(geometry) AS geometry FROM ${NAME}
+UNION ALL
+SELECT 'borders' AS kind, ST_Collect(ST_Boundary(geometry)) AS geometry FROM ${NAME}"
+
+TMPDIR="world-map.tmp"
+
+rm -rv ${TMPDIR} || true
+mkdir ${TMPDIR}
+wget ${SHP_SOURCE} -O ${TMPDIR}/${NAME}.shp
+wget ${SHX_SOURCE} -O ${TMPDIR}/${NAME}.shx
+ogr2ogr -f "GeoJSON" world-map.json ${TMPDIR}/${NAME}.shp -dialect sqlite -sql "${SQL_COMMAND}" -lco COORDINATE_PRECISION=4 -nlt MULTILINESTRING
+rm -rv ${TMPDIR}
+
-- 
2.47.3





  parent reply	other threads:[~2026-05-05  7:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-05  7:31 [PATCH datacenter-manager/yew-widget-toolkit/yew-widget-toolkit-assets v2 0/8] add a new map widget for custom views Dominik Csapak
2026-05-05  7:31 ` [PATCH yew-widget-toolkit v2 1/3] js-helper: add client-to-svg-coordinate conversion helper Dominik Csapak
2026-05-05  7:31 ` [PATCH yew-widget-toolkit v2 2/3] widget: charts: add interactive Map with zoom/pan and clustering Dominik Csapak
2026-05-05  7:31 ` [PATCH yew-widget-toolkit v2 3/3] widget: charts: add WorldMap with GeoJSON rendering Dominik Csapak
2026-05-05  7:31 ` [PATCH yew-widget-toolkit-assets v2 1/1] charts: add necessary classes for Map Dominik Csapak
2026-05-05  7:31 ` [PATCH datacenter-manager v2 1/4] lib/api/ui: add location property to remote config Dominik Csapak
2026-05-05  8:26   ` Thomas Lamprecht
2026-05-05  8:36     ` Dominik Csapak
2026-05-05  8:44       ` Thomas Lamprecht
2026-05-05  8:46         ` Dominik Csapak
2026-05-05  7:31 ` [PATCH datacenter-manager v2 2/4] lib/api: add new 'remote-list' info to the resource status Dominik Csapak
2026-05-05  7:31 ` Dominik Csapak [this message]
2026-05-05  7:31 ` [PATCH datacenter-manager v2 4/4] ui: views: add map component Dominik Csapak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260505073203.398548-8-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pdm-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal