<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);">
Dear Steve,</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);">
<br style="overflow-wrap: break-word; font-family: "Segoe UI"">
</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);">
Thanks for your help and here is the solution.</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);">
<br style="overflow-wrap: break-word; font-family: "Segoe UI"">
</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);">
The grid in mapcache.xml was good (same resolution as the default with 256x256, the only difference is the size of the tile)</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);">
<br style="overflow-wrap: break-word; font-family: "Segoe UI"">
</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);">
<span style="overflow-wrap: break-word; font-family: "Segoe UI""><font face="Calibri" style="overflow-wrap: break-word"><grid name="GoogleMaps512"><br style="overflow-wrap: break-word">
</font></span>
<div style="overflow-wrap: break-word; font-family: "Segoe UI""><extent>-20037508.3427892480 -20037508.3427892480 20037508.3427892480 20037508.3427892480</extent><br style="overflow-wrap: break-word">
</div>
<div style="overflow-wrap: break-word; font-family: "Segoe UI""><srs>EPSG:3857</srs><br style="overflow-wrap: break-word">
</div>
<div style="overflow-wrap: break-word; font-family: "Segoe UI""><units>m</units><br style="overflow-wrap: break-word">
</div>
<div style="overflow-wrap: break-word; font-family: "Segoe UI""><size>512 512</size><br style="overflow-wrap: break-word">
</div>
<div style="overflow-wrap: break-word; font-family: "Segoe UI""><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><br style="overflow-wrap: break-word">
</div>
<font face="Calibri" style="overflow-wrap: break-word; font-family: "Segoe UI""><span style="overflow-wrap: break-word"></grid></span><br style="overflow-wrap: break-word">
</font></div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);">
<span style="overflow-wrap: break-word; font-family: "Segoe UI""><br style="overflow-wrap: break-word">
</span></div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);">
<span style="overflow-wrap: break-word; font-family: "Segoe UI""><font face="Calibri" style="overflow-wrap: break-word">The problem was in the OL configuration, when you said that the tilesize is something else, I suppose that the resolution also changes without
 to do anything. The solution was to make another tilegrid configuration like that and to bind it to the source.</font></span></div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);">
<span style="overflow-wrap: break-word; font-family: "Segoe UI""><br style="overflow-wrap: break-word">
</span></div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);">
<span style="overflow-wrap: break-word; font-family: "Segoe UI""><font face="Calibri" style="overflow-wrap: break-word">var projExtent = ol.proj.get('EPSG:3857').getExtent();<br style="overflow-wrap: break-word">
</font></span>
<div style="overflow-wrap: break-word; font-family: "Segoe UI"">var startResolution = ol.extent.getWidth(projExtent) / 256;<br style="overflow-wrap: break-word">
</div>
<div style="overflow-wrap: break-word; font-family: "Segoe UI"">var resolutions = new Array(22);<br style="overflow-wrap: break-word">
</div>
<div style="overflow-wrap: break-word; font-family: "Segoe UI"">
<div style="overflow-wrap: break-word">var tileSize = 512;<br style="overflow-wrap: break-word">
</div>
<div style="overflow-wrap: break-word">var urlTemplate = '/GoogleMaps512/{z}/{x}/{y}.png';</div>
<br style="overflow-wrap: break-word">
</div>
<div style="overflow-wrap: break-word; font-family: "Segoe UI"">for (var i = 0, ii = resolutions.length; i < ii; ++i) {<br style="overflow-wrap: break-word">
</div>
<div style="overflow-wrap: break-word; font-family: "Segoe UI"">  resolutions[i] = startResolution / Math.pow(2, i);<br style="overflow-wrap: break-word">
</div>
<div style="overflow-wrap: break-word; font-family: "Segoe UI"">}<br style="overflow-wrap: break-word">
</div>
<div style="overflow-wrap: break-word; font-family: "Segoe UI""><br style="overflow-wrap: break-word">
</div>
<div style="overflow-wrap: break-word; font-family: "Segoe UI"">var tileGrid = new ol.tilegrid.TileGrid({<br style="overflow-wrap: break-word">
</div>
<div style="overflow-wrap: break-word; font-family: "Segoe UI"">  extent: [-20037508.3427892480, -20037508.3427892480, 20037508.3427892480, 20037508.3427892480],<br style="overflow-wrap: break-word">
</div>
<div style="overflow-wrap: break-word; font-family: "Segoe UI"">  resolutions: resolutions,<br style="overflow-wrap: break-word">
</div>
<div style="overflow-wrap: break-word; font-family: "Segoe UI"">  tileSize: [512, 512]<br style="overflow-wrap: break-word">
</div>
<div style="overflow-wrap: break-word; font-family: "Segoe UI"">});<br style="overflow-wrap: break-word">
</div>
<div style="overflow-wrap: break-word; font-family: "Segoe UI""><br style="overflow-wrap: break-word">
</div>
<div style="overflow-wrap: break-word; font-family: "Segoe UI"">var source1 = new ol.source.XYZ({<br style="overflow-wrap: break-word">
</div>
<div style="overflow-wrap: break-word; font-family: "Segoe UI"">url: urlTemplate,<br style="overflow-wrap: break-word">
</div>
<div style="overflow-wrap: break-word; font-family: "Segoe UI"">tileSize: tileSize,<br style="overflow-wrap: break-word">
</div>
<div style="overflow-wrap: break-word; font-family: "Segoe UI"">    tileGrid: tileGrid<br style="overflow-wrap: break-word">
</div>
<div style="overflow-wrap: break-word; font-family: "Segoe UI"">});</div>
</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);">
<span style="overflow-wrap: break-word; font-family: "Segoe UI""><br style="overflow-wrap: break-word">
</span></div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);">
<span style="overflow-wrap: break-word; font-family: "Segoe UI""><font face="Calibri" style="overflow-wrap: break-word">With best regards,</font></span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span></span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size: 11pt;" data-ogsc=""><b>De :</b> Stephen Woodbridge <stephenwoodbridge37@gmail.com><br>
<b>Envoyé :</b> 9 mars 2020 16:46<br>
<b>À :</b> Jean-Philippe Chenel <jp.chenel@live.ca>; mapserver-users@lists.osgeo.org <mapserver-users@lists.osgeo.org><br>
<b>Objet :</b> Re: [mapserver-users] MapCache Larger tiles, reduce number of files</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">Are you sure you have the set the tile size correctly in OpenLayers?<br>
Because if OL is requesting tiles that you don't have it sounds like <br>
that is the reason.<br>
And if you do load tile and there is a miss-match, then I would expect <br>
the resolution of be off.<br>
<br>
Here are a few links that might help:<br>
<br>
<a href="https://openlayers.org/en/latest/examples/wms-custom-tilegrid-512x256.html" style="">https://openlayers.org/en/latest/examples/wms-custom-tilegrid-512x256.html</a><br>
<a href="https://openlayers.org/en/latest/apidoc/module-ol_tilegrid_TileGrid-TileGrid.html" style="">https://openlayers.org/en/latest/apidoc/module-ol_tilegrid_TileGrid-TileGrid.html</a><br>
<a href="https://stackoverflow.com/questions/57072232/how-to-change-tilesize-in-xyz-tilelayer-from-default256-256-to-something-e" style="">https://stackoverflow.com/questions/57072232/how-to-change-tilesize-in-xyz-tilelayer-from-default256-256-to-something-e</a><br>
<br>
On 3/9/2020 3:21 PM, Jean-Philippe Chenel wrote:<br>
> Steve,<br>
><br>
> It is what I supposed, but when I've generated the tiles 512x512 using <br>
> the default resolution GoogleMapCompatible, with the cache template <br>
> {z}/{x}/{y}.{ext} and loaded it in OpenLayers using ol.source.XYZ, <br>
> I've noticied that the x tile being tried to load was not in the good <br>
> range.<br>
><br>
> z/x/-y.png<br>
><br>
> Tiles generated:<br>
> .../8/37 and 38/64 and 65.png<br>
><br>
> Tiles loaded by OpenLayers (with error 404):<br>
> .../8/73 to 77/130 and 131.png<br>
><br>
> Thanks,<br>
> ------------------------------------------------------------------------<br>
> *De :* mapserver-users <mapserver-users-bounces@lists.osgeo.org> de la <br>
> part de Stephen Woodbridge <stephenwoodbridge37@gmail.com><br>
> *Envoyé :* 9 mars 2020 14:56<br>
> *À :* mapserver-users@lists.osgeo.org <mapserver-users@lists.osgeo.org><br>
> *Objet :* Re: [mapserver-users] MapCache Larger tiles, reduce number <br>
> of files<br>
> Jean-Philippe,<br>
><br>
> I don't think it works like that. Resolution is determined by zoom<br>
> factor so you generate  metatile at that resolution then you chop that<br>
> metatile in tiles of whatever size you specify. So resolution is<br>
> controled by zoom not tile size.<br>
><br>
> -Steve W<br>
><br>
> On 3/9/2020 2:45 PM, Jean-Philippe Chenel wrote:<br>
> > Hi,<br>
> ><br>
> > With MapCache, I want to generate the tiles that will be copied to a<br>
> > mobile device, on a viewer created with OpenLayers.<br>
> ><br>
> > When generating a large extent, with multiple levels of zoom, the<br>
> > files count is really big, so I want to reduce the number of files by<br>
> > increasing the tile size. I've made a test with tiles 512x512, but<br>
> > I've realized that the resolution must be changed when changing tiles<br>
> > size. So, the tiles are bigger, but changing the resolution make<br>
> > generating the same number of files.<br>
> ><br>
> > I'm open for workaround and other tricks.<br>
> ><br>
> > mapcache.xml<br>
> ><br>
> > <grid name="GoogleMaps512"><br>
> > <metadata><br>
> > <title>GoogleMaps512</title><br>
> > </metadata><br>
> > <extent>-20037508.3427892480 -20037508.3427892480 20037508.3427892480<br>
> > 20037508.3427892480</extent><br>
> > <srs>EPSG:3857</srs><br>
> > <srsalias>EPSG:900913</srsalias><br>
> > <units>m</units><br>
> > <size>512 512</size><br>
> > <resolutions>156543.0339280410 78271.51696402048 39135.75848201023<br>
> > 19567.87924100512 9783.939620502561 4891.969810251280<br>
> > 2445.984905125640 1222.992452562820 611.4962262814100<br>
> > 305.7481131407048 152.8740565703525 76.43702828517624<br>
> > 38.21851414258813 19.10925707129406 9.554628535647032<br>
> > 4.777314267823516 2.388657133911758 1.194328566955879<br>
> > 0.5971642834779395</resolutions><br>
> > </grid><br>
> ><br>
> > <cache name="tmpl_xyz" type="disk" layout="template"><br>
> > <br>
> <template>/data/mapcache/tiles/{tileset}/{grid}/{z}/{x}/{y}.{ext}</template><br>
> > </cache><br>
> ><br>
> > <tileset name="OpenStreetMap"><br>
> > <source>vmap0</source><br>
> > <cache>tmpl_xyz</cache><br>
> > <grid>GoogleMaps512</grid><br>
> > <format>PNG</format><br>
> > </tileset><br>
> ><br>
> > With best regards,<br>
> ><br>
> > _______________________________________________<br>
> > mapserver-users mailing list<br>
> > mapserver-users@lists.osgeo.org<br>
> > <a href="https://lists.osgeo.org/mailman/listinfo/mapserver-users" style="">https://lists.osgeo.org/mailman/listinfo/mapserver-users</a><br>
><br>
> _______________________________________________<br>
> mapserver-users mailing list<br>
> mapserver-users@lists.osgeo.org<br>
> <a href="https://lists.osgeo.org/mailman/listinfo/mapserver-users" style="">https://lists.osgeo.org/mailman/listinfo/mapserver-users</a><br>
<br>
</div>
</span></font></div>
</body>
</html>