diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e39fe56 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/work/ +/venv/ +/tmp/ +/out/ +/data/ +/bin/ diff --git a/build.sh b/build.sh index 2c4f25d..0f5e8c7 100755 --- a/build.sh +++ b/build.sh @@ -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 diff --git a/defs/.README.md.kate-swp b/defs/.README.md.kate-swp new file mode 100644 index 0000000..3060c4a Binary files /dev/null and b/defs/.README.md.kate-swp differ diff --git a/defs/README.md b/defs/README.md new file mode 100644 index 0000000..47c3059 --- /dev/null +++ b/defs/README.md @@ -0,0 +1 @@ +Local definitions diff --git a/defs/regions/.europe.txt.kate-swp b/defs/regions/.europe.txt.kate-swp new file mode 100644 index 0000000..bd506a9 Binary files /dev/null and b/defs/regions/.europe.txt.kate-swp differ diff --git a/defs/regions/planet.txt b/defs/regions/planet.txt new file mode 100644 index 0000000..8caa993 --- /dev/null +++ b/defs/regions/planet.txt @@ -0,0 +1,8 @@ +africa +antarctica +asia +australia-oceania +central-america +europe +north-america +south-america diff --git a/defs/regions/roots/africa.txt b/defs/regions/roots/africa.txt new file mode 100644 index 0000000..bc37157 --- /dev/null +++ b/defs/regions/roots/africa.txt @@ -0,0 +1,55 @@ +algeria +angola +benin +botswana +burkina-faso +burundi +cameroon +canary-islands +cape-verde +central-african-republic +chad +comores +congo-brazzaville +congo-democratic-republic +djibouti +egypt +equatorial-guinea +eritrea +ethiopia +gabon +ghana +guinea +guinea-bissau +ivory-coast +kenya +lesotho +liberia +libya +madagascar +malawi +mali +mauritania +mauritius +morocco +mozambique +namibia +niger +nigeria +rwanda +saint-helena-ascension-and-tristan-da-cunha +sao-tome-and-principe +senegal-and-gambia +seychelles +sierra-leone +somalia +south-africa +south-sudan +sudan +swaziland +tanzania +togo +tunisia +uganda +zambia +zimbabwe diff --git a/defs/regions/roots/asia.txt b/defs/regions/roots/asia.txt new file mode 100644 index 0000000..3b9ded8 --- /dev/null +++ b/defs/regions/roots/asia.txt @@ -0,0 +1,38 @@ +afghanistan +armenia +azerbaijan +bangladesh +bhutan +cambodia +china +east-timor +gcc-states +india +indonesia +iran +iraq +israel-and-palestine +japan +jordan +kazakhstan +kyrgyzstan +laos +lebanon +malaysia-singapore-brunei +maldives +mongolia +myanmar +nepal +north-korea +pakistan +philippines +south-korea +sri-lanka +syria +taiwan +tajikistan +thailand +turkmenistan +uzbekistan +vietnam +yemen diff --git a/defs/regions/roots/australia-oceania.txt b/defs/regions/roots/australia-oceania.txt new file mode 100644 index 0000000..16d41a0 --- /dev/null +++ b/defs/regions/roots/australia-oceania.txt @@ -0,0 +1,23 @@ +american-oceania +australia +cook-islands +fiji +ile-de-clipperton +kiribati +marshall-islands +micronesia +nauru +new-caledonia +new-zealand +niue +palau +papua-new-guinea +pitcairn-islands +polynesie-francaise +samoa +solomon-islands +tokelau +tonga +tuvalu +vanuatu +wallis-et-futuna diff --git a/defs/regions/roots/central-america.txt b/defs/regions/roots/central-america.txt new file mode 100644 index 0000000..5823b80 --- /dev/null +++ b/defs/regions/roots/central-america.txt @@ -0,0 +1,11 @@ +bahamas +belize +costa-rica +cuba +el-salvador +guatemala +haiti-and-domrep +honduras +jamaica +nicaragua +panama diff --git a/defs/regions/roots/europe.txt b/defs/regions/roots/europe.txt new file mode 100644 index 0000000..85a9748 --- /dev/null +++ b/defs/regions/roots/europe.txt @@ -0,0 +1,53 @@ +albania +alps +andorra +austria +azores +belarus +belgium +bosnia-herzegovina +britain-and-ireland +bulgaria +croatia +cyprus +czech-republic +dach +denmark +estonia +faroe-islands +finland +france +georgia +germany +great-britain +greece +guernsey-jersey +hungary +iceland +ireland-and-northern-ireland +isle-of-man +italy +kosovo +latvia +liechtenstein +lithuania +luxembourg +macedonia +malta +moldova +monaco +montenegro +netherlands +norway +poland +portugal +romania +serbia +slovakia +slovenia +spain +sweden +switzerland +turkey +ukraine +united-kingdom diff --git a/defs/regions/roots/north-america.txt b/defs/regions/roots/north-america.txt new file mode 100644 index 0000000..3f5c46e --- /dev/null +++ b/defs/regions/roots/north-america.txt @@ -0,0 +1,9 @@ +canada +greenland +mexico +us +us-midwest +us-northeast +us-pacific +us-south +us-west diff --git a/defs/regions/roots/south-america.txt b/defs/regions/roots/south-america.txt new file mode 100644 index 0000000..d315893 --- /dev/null +++ b/defs/regions/roots/south-america.txt @@ -0,0 +1,12 @@ +argentina +bolivia +brazil +chile +colombia +ecuador +guyana +paraguay +peru +suriname +uruguay +venezuela diff --git a/schema.yml b/schema.yml index 174913c..c96abfd 100755 --- a/schema.yml +++ b/schema.yml @@ -344,4 +344,3 @@ layers: attracion: [slide, water_slide, lazy_river] man_made: [pipeline] leisure: [track] -