Implement each region generation

This commit is contained in:
2026-05-10 01:17:56 +02:00
parent 81181cf78f
commit 17ab0bfb3d
14 changed files with 293 additions and 22 deletions
+77 -21
View File
@@ -5,10 +5,71 @@ if [ "$#" -ne 3 ]; then
exit 1
fi
REGION_ROOT="$1"
REGION="$2"
MEMORY="$3"
#Define functions
generate_region() {
local REGION="$1"
local REGION_ROOT="$2"
local MEMORY="${3:-8g}"
local POLY_FILE="${REGION}.poly"
mkdir -p work
wget -O "work/$POLY_FILE" \
"https://download.geofabrik.de/${REGION_ROOT}/${REGION}.poly"
mkdir -p "work/contours/$REGION_ROOT/$REGION"
pyhgtmap \
--polygon="work/$POLY_FILE" \
--step=75 \
--hgtdir=work/hgt \
--sources=view1,view3 \
--simplifyContoursEpsilon=0.001 \
-j16 \
--max-nodes-per-tile=0 \
--output-prefix="work/contours/$REGION_ROOT/$REGION/con"
rm -f work/contours.osm
# max-nodes-per-tile=0 SHOULD generate only one file
mv "work/contours/$REGION_ROOT/$REGION"/con* work/contours.osm
rm -rf "work/contours/$REGION_ROOT/"
rm -f data/contours.geojson
osmium export work/contours.osm \
-o data/contours.geojson \
--overwrite
rm -f work/contours.osm
mkdir -p "./out/$REGION_ROOT"
java -Xmx"$MEMORY" \
-jar ./bin/planetiler.jar schema.yml \
--download \
--area="${REGION}" \
--output="./out/${REGION_ROOT}/${REGION}.mbtiles" \
--no-simplify \
--simplify-tolerance-at-max-zoom=0 \
--no-feature-merge \
--simplify-tolerance=0
}
generate_root() {
local REGION_ROOT="$1"
local REGION="$2"
if [[ "$REGION" == "each" ]]; then
while IFS= read -r REGION; do
generate_region "$REGION" "$REGION_ROOT" "$MEMORY"
done < "defs/regions/roots/${REGION_ROOT}.txt"
else
generate_region "$REGION" "$REGION_ROOT" "$MEMORY"
fi
}
#Prepare environment
if [ ! -f ./bin/planetiler.jar ]; then
mkdir -p ./bin
wget -O ./bin/planetiler.jar https://github.com/onthegomap/planetiler/releases/latest/download/planetiler.jar
@@ -20,26 +81,21 @@ if [ ! -d "$VENV_DIR" ]; then
. "$VENV_DIR/bin/activate"
pip install --upgrade pip
pip install pyhgtmap
source "$VENV_DIR/bin/activate"
else
source "$VENV_DIR/bin/activate"
fi
POLY_FILE="${REGION}.poly"
mkdir -p work
wget -O "work/$POLY_FILE" "https://download.geofabrik.de/${REGION_ROOT}${REGION}.poly"
REGION_ROOT="$1"
REGION="$2"
MEMORY="$3"
rm -f data/contours.osm
pyhgtmap --polygon="work/$POLY_FILE" --step=75 --hgtdir=work/hgt --sources=view1,view3 --simplifyContoursEpsilon=0.001 -j16 --max-nodes-per-tile=0 --output-prefix data/contours
osmium export data/contours.osm -o data/contours.geojson --overwrite
rm -f data/contours.osm
mkdir -p ./out
java -Xmx"$MEMORY" -jar ./bin/planetiler.jar schema.yml \
--download \
--area=${REGION} \
--output="./out/${REGION}.mbtiles" \
--no-simplify \
--simplify-tolerance-at-max-zoom=0 \
--no-feature-merge \
--simplify-tolerance=0
#Generate
if [[ "$REGION_ROOT" == "each" ]]; then
while IFS= read -r REGION_ROOT; do
# Straight up just ignore REGION here
generate_root "$REGION_ROOT" "each" "$MEMORY"
done < "defs/regions/planet.txt"
else
generate_root "$REGION_ROOT" "$REGION" "$MEMORY"
fi