Awesome
Planetiler Examples
This repo is a template for writing a standalone Java profile to make vector tiles with planetiler.
Until recently you needed to set up a build tool like maven or gradle to write a custom Java planetiler profile. Java 22 adds the ability to run multi-file programs directly from .java files without a compile step, and vscode's Extension Pack for Java lets you easily edit and debug simple Java projects like this.
To get started:
-
Clone this repo
-
Install Java 22 or later. You can download the Java JDK (not JRE) using a package installer for windows or mac from https://adoptium.net/temurin/releases/?version=22 or get the tar.gz/zip file and add the enclosed
<details> <summary>Linux Instructions</summary>bin/java
file to your pathDownload JDK .tar.gz version 22 for your architecture from https://adoptium.net/temurin/releases/?version=22 then:
</details>tar -xzvf OpenJDK22U-jdk_x64_linux_hotspot_22.0.1_8.tar.gz sudo mv jdk-22.0.1+8 /usr/lib/jvm/ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-22.0.1+8/bin/java 1 sudo update-alternatives --config java # and select openjdk-22
-
Download latest planetiler release jar:
wget https://github.com/onthegomap/planetiler/releases/latest/download/planetiler.jar
Then run the profile:
java -cp planetiler.jar Power.java
It should create a file power.pmtiles
showing powerlines in Rhode Island that you can inspect with https://pmtiles.io
IDE Setup
- Install VSCode and the Extension Pack for Java
- In VSCode, click
File -> Open
and navigate to Planetiler directory (If VSCode asks then clickYes I trust the authors
) - Open
Power.java
, it should automatically recognize this is a Java project and addplanetiler.jar
to the project classpath. - Click
Run
button that shows up above thepublic static void main(String[] args)
method.
Docker
You can also run within docker by using:
docker run -v$(pwd):/data --workdir=/data docker.io/library/eclipse-temurin:22-jdk java -cp planetiler.jar Power.java
NOTE: You will still need to download the JDK to edit with vscode.
Next Steps
- Run the profile with other regions from geofabrik by adding
--area=australia
- Learn Java basics: https://www.baeldung.com/java-tutorial (chatgpt is also useful when getting started)
- Learn more about working with Java in vscode: https://code.visualstudio.com/docs/java/java-tutorial
- Read through the other example profiles in this repo to learn what you can do with planetiler
- Add example yaml test cases for a profile like
overturelayers/test.yml
to ensure your profile maps input source features to expected output vector tile features.
You should be able to start a simple profile in one file, split out into multiple files as complexity grows, and only introduce a build tool if you need to manage external dependencies. planetiler.jar
already contains the most popular dependencies you are likely to need like Google guava, JTS, readers for openstreetmap, shapefiles, geopackage, and geoparquet and writers for mbtiles and pmtiles archives.