5

I am using GeoServer and seed tiles on my server. The tiles are created successfully but i dont know which pattern the directory structure is following... (i.e. .../EPSG_4326_05/0_0/00_06.png) I want to use the tiles in a OpenLayers application and there i want to use a OSM source which is using the XYZ-pattern which is commonly used as URL pattern for tile-serving. Is there a way to tell the geoserver it should create the tiles with the XYZ structure?

Martin Bauer
  • 71
  • 1
  • 1
  • 4
  • Posted the question on gis.stackexchange.com: https://gis.stackexchange.com/questions/242389/serve-geoserver-tiles-in-xyz-format – Martin Bauer Jun 01 '17 at 07:35

3 Answers3

6

Cool, I had the same question one hour ago. Here goes the summary.

Note:

What the OP calls XYZ format is the format popularized by Google Maps where a global/basemap is server-side split and served as tiles in a {z}/{x}/{y} format where zoom, latitude and longitude are represented internally [1]. Effectively, the name of the service providing such "format" is Tile Map Service (TMS)[2], and GeoServer does provide such service [3]. XYZ is just the name of the class in OpenLayers used to access a TMS server [4].

That being said, here is how you'd do to have a TMS service running between your GeoServer and OpenLayers:

  • Check if your GeoServer' Caching Defaults has GeoWebCache and the TMS service enabled. I am currently using GS-2.14.3 and those are enabled by default.

With GWC and TMS enabled you should see your raster layers listed under http://localhost:8080/gwc/service/tms/1.0.0 (or, in general, <geoserver-path>/gmc/service/tms/1.0.0).

Then, you just have to call one of those TileMaps from OpenLayer:

var tileURL = "<tilemap-from-gwc-list-above>" + "/{z}/{x}/{-y}.jpg" // or '.png'

var map = new ol.Map(<your params here>);

var bm = new ol.layer.Tile({
  source: new ol.source.XYZ({
    url: tileURL
  })
})
map.addLayer(bm)

Hope that helps. Cheers.


Refs:

  1. Google/TMS format: https://www.maptiler.com/google-maps-coordinates-tile-bounds-projection/
  2. TMS specification: https://wiki.osgeo.org/wiki/Tile_Map_Service_Specification
  3. TMS in Leaflet: https://leafletjs.com/examples/wms/wms.html#tms-in-leaflet
  4. TMS/XYZ OpenLayers: https://openlayers.org/en/latest/apidoc/module-ol_source_XYZ-XYZ.html
Brandt
  • 5,058
  • 3
  • 28
  • 46
4

This may be too late by here is my XYZ URL for geoserver layer:

http://localhost/gwc/service/tms/1.0.0/gis:service@EPSG%3A900913@png/{z}/{x}/{-y}.png

Geoserver will cache the tiles automatically as you request through URL.

PeterS
  • 139
  • 8
Anos K. Mhazo
  • 365
  • 3
  • 11
  • Can you provide a pointer to documentation? Do I need some extension to have the `tms` end point available? I've tried different urls, with no luck, like `http://localhost:8080/geoserver/gwc/tms/`, `http://localhost:8080/geoserver/gwc/`. – jgrocha Jan 21 '19 at 23:08
  • 1
    Just found out: `http://localhost:8080/geoserver/gwc/service/tms/1.0.0`. Documentation available at: https://docs.geoserver.org/stable/en/user/geowebcache/webadmin/defaults.html. – jgrocha Jan 21 '19 at 23:12
  • Sorry took so long to respond. But yes thats the link ;) – Anos K. Mhazo Jan 23 '19 at 14:06
0

GeoServer (actually GeoWebCache) can provides a number of end points that can server tiles.

None of these uses the so called XYZ system (because that isn't a standard) but OpenLayers has a Tiled Layer that can handle TMS and WMTS servers using the TileImage source.

Ian Turton
  • 10,018
  • 1
  • 28
  • 47
  • It would be important to serve the tiles as images just using our nginx-server. If i use the WMTS source of openlayers, serving the tiles would be done via geoserver and tomcat.. i just want to serve the tiles as simple images – Martin Bauer Jun 01 '17 at 07:11
  • I've never tried but I think that OpenLayers using a REST wmts (or TMS) scheme can read those tiles directly. – Ian Turton Jun 01 '17 at 07:42
  • its supported now ... like other answers suggest – Sheece Gardazi Sep 02 '23 at 08:06