0

My goal is to use mapcache to generate a ZXY tileset. This tileset can then be used directly by the client with no server requirement.

The reason for mapcache is that I have a set of mapserver map files that contain all of my styling.

I have configured mapcache.xml as follows:-

<cache name="disk_test" type="disk" layout="template">
    <template>/tmp/disk_test/rbwm_mastermap/{z}/{x}/{y}.{ext}</template>
</cache>

<tileset name="test_zxy">
    <source>MY MAPFILE SOURCE</source>
    <cache>disk_test</cache>
    <grid>ZXY</grid>
    <format>PNG</format>
    <metatile>1 1</metatile>
    <metabuffer>10</metabuffer>
    <expires>3600</expires>
    <auto_expire>2678400</auto_expire>
</tileset>

<grid name="ZXY">
    <size>256 256</size>
    <extent>-20037508.3427892480 -20037508.3427892480 20037508.3427892480 20037508.3427892480</extent>
    <srs>EPSG:3857</srs>
    <units>m</units>
    <resolutions>2000 1000 500 400 200 100 50 25 20 10 9 8 7 6 5 4 3 2.5 2 1.5 1 0.3 0.2</resolutions>
</grid>

The following request creates a tile in 20/77961/104498.png

SERVICE=WMS&VERSION=1.1.1&
REQUEST=GetMap&
LAYERS=test_zxy&
WIDTH=256&HEIGHT=256&
FORMAT=image/png&
SRS=EPSG:3857&
TILED=true&
DPI=72&
MAP_RESOLUTION=72&
FORMAT_OPTIONS=dpi:72&
TRANSPARENT=TRUE&BBOX=-79492.34278900176286697,6713979.65721099823713303,-79236.34278900176286697,6714235.65721099823713303

My calculations show that this is wrong as it should be closer to:-

20/522208/348614.png

Am I doing something wrong in my grid or template?

  • Just in case it helps anyone else. To use these tiles in Openlayers you will need to use -y instead of y in the url:- var map = new ol.Map({ target: 'map', layers: [ new ol.layer.Tile({ source: new ol.source.XYZ({ url: 'SERVER{z}/{x}/{-y}.png' }) }) ], view: new ol.View({ center: [-79492.34278900176286697,6713979.65721099823713303], zoom: 20 }) }); – CitizenFish May 22 '17 at 14:12
1

Your resolutions do not look correct. Try:

<resolutions>156543.0339280410 78271.51696402048 39135.75848201023 19567.87924100512 9783.939620502561 4891.969810251280 2445.984905125640 1222.992452562820 611.4962262814100 305.7481131407048 152.8740565703525 76.43702828517624 38.21851414258813 19.10925707129406 9.554628535647032 4.777314267823516 2.388657133911758 1.194328566955879 0.5971642834779395</resolutions>
  • Spot on thanks! Note well I had to add a few more to go down further zoom levels <resolutions>156543.0339280410 78271.51696402048 39135.75848201023 19567.87924100512 9783.939620502561 4891.969810251280 2445.984905125640 1222.992452562820 611.4962262814100 305.7481131407048 152.8740565703525 76.43702828517624 38.21851414258813 19.10925707129406 9.554628535647032 4.777314267823516 2.388657133911758 1.194328566955879 0.5971642834779395,0.2984505969011938, 0.1492252984505969, 0.07461264922529845</resolutions> – CitizenFish May 18 '17 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.