OpenMapTiles v3.14 does not include the tracktype
tag. This gist shows how to add it with planetiler.
Fork OpenMapTiles, create a tracktype
branch, add the following lines (see https://github.com/wipfli/openmaptiles/commit/b6f74e70e66a0007a21b94e0eea5c3505f91f7f6):
To layers/transportation/mapping.yaml
:
expressway_field: &expressway
key: expressway
name: expressway
type: bool
+tracktype_field: &tracktype
+ key: tracktype
+ name: tracktype
+ type: string
...
- *expressway
+ - *tracktype
To layers/transportation/transportation.yaml
:
surface:
description: |
Values of [`surface`](https://wiki.openstreetmap.org/wiki/Key:surface) tag devided into 2 groups `paved` (paved, asphalt, cobblestone, concrete, concrete:lanes, concrete:plates, metal, paving_stones, sett, unhewn_cobblestone, wood) and `unpaved` (unpaved, compacted, dirt, earth, fine_gravel, grass, grass_paver, gravel, gravel_turf, ground, ice, mud, pebblestone, salt, sand, snow, woodchips).
values:
- paved
- unpaved
+ tracktype:
+ description: |
+ Original value of the [`tracktype`](http://wiki.openstreetmap.org/wiki/Key:tracktype) tag.
Fork planetiler.
Point the automatic java code generation to your OpenMapTiles fork (see https://github.com/wipfli/planetiler/commit/f720f60a9a16f457a54cbcf17253dca5563db4de).
Edit in planetiler-basemap/src/main/java/com/onthegomap/planetiler/basemap/Generate.java
:
- String base = "https://raw.githubusercontent.com/openmaptiles/openmaptiles/" + tag + "/";
+ String base = "https://raw.githubusercontent.com/wipfli/openmaptiles/tracktype/";
Regenerate the OpenMapTiles java code from your updated OpenMapTiles yaml files:
scripts/regenerate-openmaptiles.sh
Add tracktype
to planetiler-basemap/src/main/java/com/onthegomap/planetiler/basemap/layers/Transportation.java
:
.setAttrWithMinzoom(Fields.ONEWAY, nullIfInt(element.isOneway(), 0), 12)
.setAttrWithMinzoom(Fields.SURFACE, surface(element.surface()), 12)
+ .setAttrWithMinzoom(Fields.TRACKTYPE, nullIfEmpty(element.tracktype()), 12)
.setMinPixelSize(0) // merge during post-processing, then limit by size
Compile planetier:
./mvnw clean package
Run planetiler:
java -jar planetiler-dist/target/*with-deps.jar --force=true --area=switzerland
Inspect tiles:
sudo docker run --rm -it -v "$(pwd)/data":/data -p 8080:8080 maptiler/tileserver-gl -p 8080
It seems now
planetiler-basemap
is exhcanged withplanetiler-openmaptiles
and same goes withbasemap
:./planetiler-openmaptiles/src/main/java/org/openmaptiles/Generate.java
And since it seems to be a submodule there are multiple hoops one have to jump through, since the submodule have to be forked, the new submodule have to be set, and only then can one modify
Generate.java
.And similarly Transportation have moved over to:
./planetiler-openmaptiles/src/main/java/org/openmaptiles/layers/Transportation.java
I guess regenerate is after:
cd planetiler-openmaptiles
otherwise it fails.
Anyway, shouldn't the regenerate script called as
./scripts/regenerate-openmaptiles.sh tracktype https://raw.githubusercontent.com/wipfli/openmaptiles/
?(and possibly no need to patch Generate.java?)
Oh and better not call regenerate script anymore but manually `java -cp target/*-with-deps.jar org.openmaptiles.Generate -tag=tracktype -base-url="https://raw.githubusercontent.com/wiplfli/openmaptiles/"`` because if there was any error in the build then the generate code will be destroyed and cannot be recreated anymore (since regenerating it would require a clean build, I've been bitten by that). In fact it shall be copied to a safe place since any rebuild will clean it up.