Comments (2)
from planetiler.
What do people think of a single script that builds the arguments/JVM options based on the area being built and method used to run (docker, jar, maven build)
#!/usr/bin/env bash
# Usage: quickstart.sh {--docker, --jar, --source} {--planet,--area=monaco,massachusetts,etc.} [--memory=5g] other args...
set -o errexit
set -o pipefail
set -o nounset
JAVA="${JAVA:-java}"
METHOD="build"
AREA="monaco"
STORAGE="mmap"
PLANETILER_ARGS=("--download" "--force")
MEMORY=""
DRY_RUN=""
DOCKER_DIR="$(pwd)/data"
# Parse some args into vars, pass the rest through to planetiler
while [[ $# -gt 0 ]]; do
case $1 in
--jar) METHOD="jar" ;;
--build|--source) METHOD="build" ;;
--docker) METHOD="docker" ;;
--dockerdir=*) DOCKER_DIR="${1#*=}" ;;
--dockerdir) DOCKER_DIR="$2"; shift ;;
--area=*) AREA="${1#*=}" ;;
--area) AREA="$2"; shift ;;
--planet) AREA="planet" ;;
--memory=*) MEMORY="${MEMORY:-"-Xmx${1#*=}"}" ;;
--memory) MEMORY="${MEMORY:-"-Xmx$2"}"; shift ;;
--ram) STORAGE="ram" ;;
--dry-run) DRY_RUN="true" ;;
*) PLANETILER_ARGS+=("$1") ;;
esac
shift
done
PLANETILER_ARGS+=("--area=$AREA")
PLANETILER_ARGS+=("--storage=$STORAGE")
# Configure memory settings based on the area being built
case $AREA in
planet)
PLANETILER_ARGS+=("--nodemap-type=array" "--download-threads=20" "--download-chunk-size-mb=500")
case "$STORAGE" in
ram) MEMORY="${MEMORY:-"-Xmx150g"}" ;;
mmap) MEMORY="${MEMORY:-"-Xmx30g -Xmn15g"}" ;;
esac
;;
monaco)
# Use mini extracts for monaco
PLANETILER_ARGS+=("--water-polygons-url=https://github.com/onthegomap/planetiler/raw/main/planetiler-core/src/test/resources/water-polygons-split-3857.zip")
PLANETILER_ARGS+=("--water-polygons-path=data/sources/monaco-water.zip")
PLANETILER_ARGS+=("--natural-earth-url=https://github.com/onthegomap/planetiler/raw/main/planetiler-core/src/test/resources/natural_earth_vector.sqlite.zip")
PLANETILER_ARGS+=("--natural-earth-path=data/sources/monaco-natural_earth_vector.sqlite.zip")
;;
esac
# For extracts, use default nodemap type (sortedtable) and -Xmx (25% of RAM up to 25GB) and hope for the best.
# You can set --memory=5g if you want to change it.
JVM_ARGS="-XX:+UseParallelGC $MEMORY"
echo "METHOD=\"$METHOD\""
echo "JVM_ARGS=\"${JVM_ARGS}\""
echo "PLANETILER_ARGS=\"${PLANETILER_ARGS[*]}\""
echo "DRY_RUN=\"${DRY_RUN:-false}\""
echo ""
sleep 3
function run() {
echo "$ $*"
if [ "$DRY_RUN" != "true" ]
then
eval "$*"
fi
}
function check_java_version() {
if [ -z "$(which java)" ]; then
echo "java not found on path"
exit 1
else
OUTPUT="$($JAVA -jar "$1" --help 2>&1 || echo OK)"
if [[ "$OUTPUT" =~ "UnsupportedClassVersionError" ]]; then
echo "Wrong version of java installed, need at least 16 but found:"
$JAVA --version
exit 1
fi
fi
}
# Run planetiler
case $METHOD in
docker)
run docker run -e JAVA_TOOL_OPTIONS=\'"${JVM_ARGS}"\' -v "$DOCKER_DIR":/data ghcr.io/onthegomap/planetiler:latest "${PLANETILER_ARGS[@]}"
;;
jar)
run wget -nc https://github.com/onthegomap/planetiler/releases/latest/download/planetiler.jar
check_java_version planetiler.jar
run "$JAVA" "${JVM_ARGS}" -jar planetiler.jar "${PLANETILER_ARGS[@]}"
;;
build)
run ./mvnw -DskipTests --projects planetiler-dist -am clean package
run "$JAVA" "${JVM_ARGS}" -jar planetiler-dist/target/*with-deps.jar "${PLANETILER_ARGS[@]}"
;;
esac
The alternative would be seperate scripts with the full commands inlined, something like:
- quickstart-planet-docker.sh
- quickstart-planet-jar.sh
- quickstart-planet-from-source.sh
- quickstart-extract-docker.sh
- quickstart-extract-jar.sh
- quickstart-extract-from-source.sh
from planetiler.
Related Issues (20)
- [BUG] Broken geometry of admin_level=4 boundary HOT 3
- [FEATURE] Configure zoom levels per layer HOT 3
- [BUG] download missing latest osm file HOT 1
- [BUG] Error when building planet tiles: "Protocol message contained an invalid tag (zero)" HOT 2
- Support Overture Map format HOT 18
- About the display layer of place name labels HOT 1
- Multiple areas support? HOT 2
- House number is generated for every primative with addr:housenumber key HOT 1
- [FEATURE] Merge with already existing tiles HOT 2
- Prefer name statements over Wikidata labels HOT 2
- [FEATURE] Log problematic geometry causing JTS exceptions HOT 22
- [FEATURE] Min polygon area for including center point
- [FEATURE] Expose OSM entity metadata in the process feature context HOT 2
- [FEATURE] Lua profile followups
- [BUG] US admin level 4 boundary lines appear incomplete HOT 3
- Tilejson attributes missing attributes added or removed during post-processing
- [BUG] tiles missing >= zoom 7 HOT 13
- [FEATURE] Log planet version being used HOT 2
- [BUG] Charging stations won't be exported HOT 4
- [FEATURE] Add arbitrary extra metadata using the Profile interface
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from planetiler.