TL;DR : skip to the guide, follow the pretty pictures, create static cache for image or vector tiles in any format.
This one is more of a virtual post-it note than anything else.
The first time I had to create a static cache of tiles (vector or image) from GeoServer I had to scrape each tile with a python script, that both took a long time, and made me work way too hard. That was because before GeoServer 2.17.0 it wasn't possible to create a cache like that directly from GeoServer.
That does not mean you couldn't serve tiles in XYZ formatting ({zoom}/{x}/{y}.{extension})
, you could, but not generate a static cache you could just throw up on S3 and make available everywhere without needing to startup the actual server.
What Changed in GeoServer 2.17?
The developers added some GeoWebCache love as they called it.
meaning four things:
- Much better startup performance when integrated in GeoServer, the time to load the tiled layers configuration is a fraction of what it used to be.
- Much faster tile layer listing in the GeoServer “tile layers” page
- File system tile layout can be configured between classic (small folders), XYZ and TMS (for static cache generation)
- Better control over failed tile seed operations. Seeding threads used to stop at the first failure, now error tolerance can be configured on the single thread and across the seed job
Unfortunately there wasn't a guide that could explain how...
So I had to learn it, and the first time it took me about a day until i figured out how and got my cache set up.
Then I forgot how to do it.
Last week I came across this question : Generate GeoJSON tile layers from Shapefile.
And then I noticed that even though I knew it was possible, and even though the question had a bounty, nobody answered it.
So after relearning how to create a XYZ tile cache (which s also called SLIPPY, something I should remember next time) I answered the question and got my bounty.
How It's Done?
After publishing a layer in Geoserver, meaning:
1. Created or used an existing workspace.
2. Created a data store (can be file or DB based)
3. Published a Layer from the data store.
(Guides for all this can be found here: Publishing A Shapefile, Publishing a PostGIS table)
What you need to do is go to Tile Caching → BlobStores
And create a new File Blobstore with the following settings:
- A Base directory where all the new layer/layer groups folder will be created.
- Tiles directory layout should be SLIPPY, not GeoWebCache Default which can't be translated directly without GeoWebCache and not TMS Which uses a reverse Y coordinate.
What you need to do is go to the layer (or layer group) you want to create tiles from.
And set that layer to use the blobstore you created.
While You are there, make sure that the format you want to consume the tiles in is switched on.
You can now seed your static cache and find your files inside the folder of the blob store.
In this example the guy asked about creating a geojson tile cache, but you can just change the format.
The end result can be uploaded as is anywhere to be used as a static cache.
And that's it, a bit roundabout but gets the job done.