Dear Steve,

Thanks for your help and here is the solution.

The grid in mapcache.xml was good (same resolution as the default with 256x256, 
the only difference is the size of the tile)

<grid name="GoogleMaps512">
<extent>-20037508.3427892480 -20037508.3427892480 20037508.3427892480 
20037508.3427892480</extent>
<srs>EPSG:3857</srs>
<units>m</units>
<size>512 512</size>
<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>
</grid>

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.

var projExtent = ol.proj.get('EPSG:3857').getExtent();
var startResolution = ol.extent.getWidth(projExtent) / 256;
var resolutions = new Array(22);
var tileSize = 512;
var urlTemplate = '/GoogleMaps512/{z}/{x}/{y}.png';

for (var i = 0, ii = resolutions.length; i < ii; ++i) {
  resolutions[i] = startResolution / Math.pow(2, i);
}

var tileGrid = new ol.tilegrid.TileGrid({
  extent: [-20037508.3427892480, -20037508.3427892480, 20037508.3427892480, 
20037508.3427892480],
  resolutions: resolutions,
  tileSize: [512, 512]
});

var source1 = new ol.source.XYZ({
url: urlTemplate,
tileSize: tileSize,
    tileGrid: tileGrid
});

With best regards,

________________________________
De : Stephen Woodbridge <[email protected]>
Envoyé : 9 mars 2020 16:46
À : Jean-Philippe Chenel <[email protected]>; [email protected] 
<[email protected]>
Objet : Re: [mapserver-users] MapCache Larger tiles, reduce number of files

Are you sure you have the set the tile size correctly in OpenLayers?
Because if OL is requesting tiles that you don't have it sounds like
that is the reason.
And if you do load tile and there is a miss-match, then I would expect
the resolution of be off.

Here are a few links that might help:

https://openlayers.org/en/latest/examples/wms-custom-tilegrid-512x256.html
https://openlayers.org/en/latest/apidoc/module-ol_tilegrid_TileGrid-TileGrid.html
https://stackoverflow.com/questions/57072232/how-to-change-tilesize-in-xyz-tilelayer-from-default256-256-to-something-e

On 3/9/2020 3:21 PM, Jean-Philippe Chenel wrote:
> Steve,
>
> It is what I supposed, but when I've generated the tiles 512x512 using
> the default resolution GoogleMapCompatible, with the cache template
> {z}/{x}/{y}.{ext} and loaded it in OpenLayers using ol.source.XYZ,
> I've noticied that the x tile being tried to load was not in the good
> range.
>
> z/x/-y.png
>
> Tiles generated:
> .../8/37 and 38/64 and 65.png
>
> Tiles loaded by OpenLayers (with error 404):
> .../8/73 to 77/130 and 131.png
>
> Thanks,
> ------------------------------------------------------------------------
> *De :* mapserver-users <[email protected]> de la
> part de Stephen Woodbridge <[email protected]>
> *Envoyé :* 9 mars 2020 14:56
> *À :* [email protected] <[email protected]>
> *Objet :* Re: [mapserver-users] MapCache Larger tiles, reduce number
> of files
> Jean-Philippe,
>
> I don't think it works like that. Resolution is determined by zoom
> factor so you generate  metatile at that resolution then you chop that
> metatile in tiles of whatever size you specify. So resolution is
> controled by zoom not tile size.
>
> -Steve W
>
> On 3/9/2020 2:45 PM, Jean-Philippe Chenel wrote:
> > Hi,
> >
> > With MapCache, I want to generate the tiles that will be copied to a
> > mobile device, on a viewer created with OpenLayers.
> >
> > When generating a large extent, with multiple levels of zoom, the
> > files count is really big, so I want to reduce the number of files by
> > increasing the tile size. I've made a test with tiles 512x512, but
> > I've realized that the resolution must be changed when changing tiles
> > size. So, the tiles are bigger, but changing the resolution make
> > generating the same number of files.
> >
> > I'm open for workaround and other tricks.
> >
> > mapcache.xml
> >
> > <grid name="GoogleMaps512">
> > <metadata>
> > <title>GoogleMaps512</title>
> > </metadata>
> > <extent>-20037508.3427892480 -20037508.3427892480 20037508.3427892480
> > 20037508.3427892480</extent>
> > <srs>EPSG:3857</srs>
> > <srsalias>EPSG:900913</srsalias>
> > <units>m</units>
> > <size>512 512</size>
> > <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>
> > </grid>
> >
> > <cache name="tmpl_xyz" type="disk" layout="template">
> >
> <template>/data/mapcache/tiles/{tileset}/{grid}/{z}/{x}/{y}.{ext}</template>
> > </cache>
> >
> > <tileset name="OpenStreetMap">
> > <source>vmap0</source>
> > <cache>tmpl_xyz</cache>
> > <grid>GoogleMaps512</grid>
> > <format>PNG</format>
> > </tileset>
> >
> > With best regards,
> >
> > _______________________________________________
> > mapserver-users mailing list
> > [email protected]
> > https://lists.osgeo.org/mailman/listinfo/mapserver-users
>
> _______________________________________________
> mapserver-users mailing list
> [email protected]
> https://lists.osgeo.org/mailman/listinfo/mapserver-users

_______________________________________________
mapserver-users mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/mapserver-users

Reply via email to