Discussion:
mapcache WMTS - TMS one tile offset
mapserver
2014-10-10 20:12:48 UTC
Permalink
Disclaimer: I have asked this question already on openlayers-users, but not
received any answer
---

I have set up a mapserver/mapcache service for tiled background maps, which
should offer WMTS and TMS services
in the EPSG:31468 projection.

The TMS tiles I've verified to be correctly placed against a standard wms layer,
however the WMTS tiles get placed with
a one tile offset to the south compared to the TMS tiles.

Please see the screenshot:
Loading Image...

The grid definition is as follows:

<grid name="MUC31468">
<metadata>
<title>Mapcache Service City of Munich EPSG 31468</title>
</metadata>
<srs>EPSG:31468</srs>
<size>256 256</size>
<extent>4440016 5313983 4492016 5359983</extent>
<units>m</units>
<resolutions>141.11153491115225 70.55561745557612
42.33331047334567 35.27775872778806 26.458319045841048
17.63887936389403 8.819439681947015 3.527775872778806
2.6458319045841043 1.763887936389403 0.8819439681947016
0.35277758727788067 0.17638879363894033</resolutions>
</grid>

and the tileset

<tileset name="karte_2014-1">
<source>karte_2014-1</source>
<cache>disk</cache>
<metadata>
<title>karte_2014-1</title>
<abstract></abstract>
</metadata>
<format>PNG</format>
<metatile>5 5</metatile>
<metabuffer>10</metabuffer>
<dimensions>
<dimension type="regex" name="MAPFILE"
default="/path/to/mapfile.map">^[a-zA-Z0-9\./]*\.map$</dimension>
</dimensions>
<grid>MUC31468</grid>
</tileset>


while the service definitions (for OpenLayers 2.13) are these:

var wmts = new OpenLayers.Layer.WMTS({
name: "WMTS basemap",
url: "http://centmap/mapcache/wmts?",
layer: "karte_2014-1",
matrixSet: "MUC31468",
format: "image/png",
style: "default",
opacity: 0.7,
maxExtent: maxExtent,
isBaseLayer: true
});

var tms = new OpenLayers.Layer.TMS(
"TMS basemap",
"http://centmap/mapcache/tms/",
{ layername: "karte_2014-1",
type: "png" }
);

Any help would be greatly appreciated.

---Markus
thomas bonfort
2014-10-14 10:13:41 UTC
Permalink
Markus,

TMS expects tiles starting at the bottom left whereas WMTS expects
them starting top left. Mapcache by default uses bottom-left ordered
grids, and creates a WMTS capabilities document that accounts for that
in the sense that the TopLeftCorner of each TileMatrix is adjusted and
may vary if the combination of your grid extents and resolutions do
not produce a stable topleftcorner for each resolution. You have
multiple ways forward:

- use a combination of grid extents and resolutions that force a
stable topleftcorner whatever the resolution. This is usually done by
using power-of-two resolutions.
- force the grid to be fixed to the top left corner instead of bottom
left. <grid><origin>top-left</origin></grid>. Your tileset will not be
compatible with TMS requests.
- use a wmts client that knows how to parse WMTS capabilities so that
the correct topleftcorner is used for each resolution
- (not sure, but check if openlayers supports overiding the topleft
origin for its grid for WMTS requests)

cheers,
thomas
Post by mapserver
Disclaimer: I have asked this question already on openlayers-users, but not
received any answer
---
I have set up a mapserver/mapcache service for tiled background maps, which
should offer WMTS and TMS services
in the EPSG:31468 projection.
The TMS tiles I've verified to be correctly placed against a standard wms
layer, however the WMTS tiles get placed with
a one tile offset to the south compared to the TMS tiles.
http://markus-spring.info/varia/wmts_tms_offset_problem.jpg
<grid name="MUC31468">
<metadata>
<title>Mapcache Service City of Munich EPSG 31468</title>
</metadata>
<srs>EPSG:31468</srs>
<size>256 256</size>
<extent>4440016 5313983 4492016 5359983</extent>
<units>m</units>
<resolutions>141.11153491115225 70.55561745557612
42.33331047334567 35.27775872778806 26.458319045841048
17.63887936389403 8.819439681947015 3.527775872778806
2.6458319045841043 1.763887936389403 0.8819439681947016
0.35277758727788067 0.17638879363894033</resolutions>
</grid>
and the tileset
<tileset name="karte_2014-1">
<source>karte_2014-1</source>
<cache>disk</cache>
<metadata>
<title>karte_2014-1</title>
<abstract></abstract>
</metadata>
<format>PNG</format>
<metatile>5 5</metatile>
<metabuffer>10</metabuffer>
<dimensions>
<dimension type="regex" name="MAPFILE"
default="/path/to/mapfile.map">^[a-zA-Z0-9\./]*\.map$</dimension>
</dimensions>
<grid>MUC31468</grid>
</tileset>
var wmts = new OpenLayers.Layer.WMTS({
name: "WMTS basemap",
url: "http://centmap/mapcache/wmts?",
layer: "karte_2014-1",
matrixSet: "MUC31468",
format: "image/png",
style: "default",
opacity: 0.7,
maxExtent: maxExtent,
isBaseLayer: true
});
var tms = new OpenLayers.Layer.TMS(
"TMS basemap",
"http://centmap/mapcache/tms/",
{ layername: "karte_2014-1",
type: "png" }
);
Any help would be greatly appreciated.
---Markus
_______________________________________________
mapserver-users mailing list
http://lists.osgeo.org/mailman/listinfo/mapserver-users
mapserver
2014-10-17 10:50:30 UTC
Permalink
Thomas,

thank you very much for explaining how to step forward to solve this problem.

With qGIS I am able to retrieve the WMTS tiles, so my next try for the web
fronted will be OL 3.0, which might have improved on that problem.

Best regards - Markus Spring
Post by thomas bonfort
Markus,
TMS expects tiles starting at the bottom left whereas WMTS expects
them starting top left. Mapcache by default uses bottom-left ordered
grids, and creates a WMTS capabilities document that accounts for that
in the sense that the TopLeftCorner of each TileMatrix is adjusted and
may vary if the combination of your grid extents and resolutions do
not produce a stable topleftcorner for each resolution. You have
- use a combination of grid extents and resolutions that force a
stable topleftcorner whatever the resolution. This is usually done by
using power-of-two resolutions.
- force the grid to be fixed to the top left corner instead of bottom
left. <grid><origin>top-left</origin></grid>. Your tileset will not be
compatible with TMS requests.
- use a wmts client that knows how to parse WMTS capabilities so that
the correct topleftcorner is used for each resolution
- (not sure, but check if openlayers supports overiding the topleft
origin for its grid for WMTS requests)
cheers,
thomas
Post by mapserver
Disclaimer: I have asked this question already on openlayers-users, but not
received any answer
---
I have set up a mapserver/mapcache service for tiled background maps, which
should offer WMTS and TMS services
in the EPSG:31468 projection.
The TMS tiles I've verified to be correctly placed against a standard wms
layer, however the WMTS tiles get placed with
a one tile offset to the south compared to the TMS tiles.
http://markus-spring.info/varia/wmts_tms_offset_problem.jpg
<grid name="MUC31468">
<metadata>
<title>Mapcache Service City of Munich EPSG 31468</title>
</metadata>
<srs>EPSG:31468</srs>
<size>256 256</size>
<extent>4440016 5313983 4492016 5359983</extent>
<units>m</units>
<resolutions>141.11153491115225 70.55561745557612
42.33331047334567 35.27775872778806 26.458319045841048
17.63887936389403 8.819439681947015 3.527775872778806
2.6458319045841043 1.763887936389403 0.8819439681947016
0.35277758727788067 0.17638879363894033</resolutions>
</grid>
and the tileset
<tileset name="karte_2014-1">
<source>karte_2014-1</source>
<cache>disk</cache>
<metadata>
<title>karte_2014-1</title>
<abstract></abstract>
</metadata>
<format>PNG</format>
<metatile>5 5</metatile>
<metabuffer>10</metabuffer>
<dimensions>
<dimension type="regex" name="MAPFILE"
default="/path/to/mapfile.map">^[a-zA-Z0-9\./]*\.map$</dimension>
</dimensions>
<grid>MUC31468</grid>
</tileset>
var wmts = new OpenLayers.Layer.WMTS({
name: "WMTS basemap",
url: "http://centmap/mapcache/wmts?",
layer: "karte_2014-1",
matrixSet: "MUC31468",
format: "image/png",
style: "default",
opacity: 0.7,
maxExtent: maxExtent,
isBaseLayer: true
});
var tms = new OpenLayers.Layer.TMS(
"TMS basemap",
"http://centmap/mapcache/tms/",
{ layername: "karte_2014-1",
type: "png" }
);
Any help would be greatly appreciated.
---Markus
_______________________________________________
mapserver-users mailing list
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Loading...