Skip to content

onthegomap/planetiler-examples

Repository files navigation

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:

  1. Clone this repo

  2. 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 bin/java file to your path

    Linux Instructions

    Download JDK .tar.gz version 22 for your architecture from https://adoptium.net/temurin/releases/?version=22 then:

    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
  3. 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

  1. Install VSCode and the Extension Pack for Java
  2. In VSCode, click File -> Open and navigate to Planetiler directory (If VSCode asks then click Yes I trust the authors)
  3. Open Power.java, it should automatically recognize this is a Java project and add planetiler.jar to the project classpath.
  4. Click Run button that shows up above the public static void main(String[] args) method.
image

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

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.

About

Example java profiles for planetiler

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages