[MapServer-users] How to handle multiple styles in MapCache?

Just van den Broecke justb4 at gmail.com
Tue Sep 17 05:21:32 PDT 2024


Almost there, two things:

- the names of your (cached) Layers are names of the tilesets like: 
'layerA_style1' etc I think)
- if you need to use WMS (tiling services like WMTS is preferred) use 
these names in LAYER=, do not use STYLES= as thes are implicit for the 
Layers.

Best is: do a REQUEST=GetCapabilities on the WMS (and WMTS) to see what 
the possible Layers and other params like projections/grids are.

Best,

Just

On 17/09/2024 12:40, Alessandro Parma wrote:
> Thanks for your reply,
> 
> That's right, the parameter is called STYLES not STYLE it was a typo in 
> my email.
> 
> It is fine for me to create multiple caches, one per each style, that is 
> expected. I've tried to follow your suggestion
> and create separate sources and tilesets for the same layer as follows:
> 
> <source name="*layerA_style1*" type="wms">
>      <getmap>
>          <params>
>              <TRANSPARENT>true</TRANSPARENT>
>              <TILED>false</TILED>
> *<LAYERS>layerA</LAYERS>
>              <STYLES>style1</STYLES>*
>          </params>
>      </getmap>
>      <http>
>          <url>http://wms-geoserver-slave-svc:8080/geoserver/wms <http:// 
> wms-geoserver-slave-svc:8080/geoserver/wms>?</url>
>      </http>
>      <timeout>10</timeout>
>      <connection_timeout>3</connection_timeout>
> </source>
> 
> <source name="*layerA_style2*" type="wms">
>      <getmap>
>          <params>
>              <TRANSPARENT>true</TRANSPARENT>
>              <TILED>false</TILED>
> *            <LAYERS>layerA</LAYERS>
>              <STYLES>style2</STYLES>*
>          </params>
>      </getmap>
>      <http>
>          <url>http://wms-geoserver-slave-svc:8080/geoserver/wms <http:// 
> wms-geoserver-slave-svc:8080/geoserver/wms>?</url>
>      </http>
>      <timeout>10</timeout>
>      <connection_timeout>3</connection_timeout>
> </source>
> 
> * <tileset name="layerA_style1">
>          <source>l**ayerA_style1**</source>*
>          <cache>multitier-cache</cache>
>          <grid use_wms_intermediate_resolutions="true">EPSG4326_512</grid>
>          <grid use_wms_intermediate_resolutions="true">EPSG3995_512</grid>
>          <grid use_wms_intermediate_resolutions="true">EPSG3857_512</grid>
>      <grid use_wms_intermediate_resolutions="true">EPSG3976_512</grid>
>          <dimensions>
>              <dimension type="regex" name="TIME" default="now">
>                  <regex>^.*$</regex>
>              </dimension>
>          </dimensions>
>          <format>MIXED</format>
>          <metatile>1 1</metatile>
>          <metabuffer>10</metabuffer>
>          <expires>604800</expires>
>      </tileset>
> 
> * <tileset name="layerA_style2">
>          <source>l**ayerA_style2**</source>*
>          <cache>multitier-cache</cache>
>          <grid use_wms_intermediate_resolutions="true">EPSG4326_512</grid>
>          <grid use_wms_intermediate_resolutions="true">EPSG3995_512</grid>
>          <grid use_wms_intermediate_resolutions="true">EPSG3857_512</grid>
>      <grid use_wms_intermediate_resolutions="true">EPSG3976_512</grid>
>          <dimensions>
>              <dimension type="regex" name="TIME" default="now">
>                  <regex>^.*$</regex>
>              </dimension>
>          </dimensions>
>          <format>MIXED</format>
>          <metatile>1 1</metatile>
>          <metabuffer>10</metabuffer>
>          <expires>604800</expires>
>      </tileset>
> 
> What I observe with this updated configuration by looking at mapcache 
> logs and the source server logs is that it
> looks like the requests are always passed through to the origin WMS 
> server and never cached in MapCache, as
> if mapcache was not matching my defined sources/tilesets. Here below two 
> sample requests:
> 
> https://mygeoserver.com/geoserver/wms? 
> SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image/ 
> png&TRANSPARENT=true&LAYERS= <https://mygeoserver.com/geoserver/wms? 
> SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image/ 
> png&TRANSPARENT=true&LAYERS=>*layerA*&STYLES=*style1*&WIDTH=512&HEIGHT=512&CRS=EPSG:4326&BBOX=0,-90,45,-45
> 
> https://mygeoserver.com/geoserver/wms? 
> SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image/ 
> png&TRANSPARENT=true&LAYERS= <https://mygeoserver.com/geoserver/wms? 
> SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image/ 
> png&TRANSPARENT=true&LAYERS=>*layerA*&STYLES=*style2*&WIDTH=512&HEIGHT=512&CRS=EPSG:4326&BBOX=0,-90,45,-45
> 
> Am I missing something in my configuration?
> 
> Another question I had while checking the documentation <https:// 
> mapserver.org/mapcache/config.html#source> is if the parameters 
> specified in the <params> are used to
> match the request to the given source (i.e. if the params in the 
> incoming request match -> this is the right source configuration to use 
> to serve the request) or
> if  instead are used to override the parameters in the original http 
> request with hardcoded values.
> 
> Thank you,
> Alessandro
> 
> 
> On Fri, Sep 13, 2024 at 11:11 PM Just van den Broecke via MapServer- 
> users <mapserver-users at lists.osgeo.org <mailto:mapserver- 
> users at lists.osgeo.org>> wrote:
> 
>     Hi Alessandro,
> 
>     I try to understand your issue. Beware, I am not a MapCache expert.
> 
>     You mention a GetMap request and STYLE (not STYLES?) parameter.
>     MapCache
>     supports tiling, like WMTS GetTile, not WMS GetMap.
> 
>     But looking at the MapCache docs (1.8 is quite old) [1]. The <getmap>
>     element within the <source> element may contain WMS parameters,
>     including STYLES. These will be sent to the WMS (GeoServer) backend (as
>     GetMap). But I see no way how one could have varying Styes for a
>     tilecache, other than a separate cache per STYLES value.
> 
>     [1] https://mapserver.org/fr/mapcache/config.html <https://
>     mapserver.org/fr/mapcache/config.html>
> 
>     Hope this helps!
> 
>     Best,
> 
>     Just
>     On 13/09/2024 17:47, Alessandro Parma via MapServer-users wrote:
>      > Dear ML,
>      >
>      > I am using MapCache version 1.8 and having issues with the caching
>      > configuration of one of the layers:
>      >
>      > The layer in question can be requested with multiple different
>     styles
>      > but it looks like the STYLE parameter in
>      > the GetMap requests is ignored and I get the same cached tiles no
>     matter
>      > what the style value of the request is.
>      >
>      > This is a snippet of the configuration:
>      > ...
>      >     <source name="mtg_fd:ir105_hrfi" type="wms">
>      >      <getmap>
>      >          <params>
>      >              <TRANSPARENT>true</TRANSPARENT>
>      >              <TILED>false</TILED>
>      >              <LAYERS>mtg_fd:ir105_hrfi</LAYERS>
>      >          </params>
>      >      </getmap>
>      >      <http>
>      >          <url>http://wms-geoserver-slave-svc:8080/geoserver/wms
>     <http://wms-geoserver-slave-svc:8080/geoserver/wms>
>      > <http://wms-geoserver-slave-svc:8080/geoserver/wms <http://wms-
>     geoserver-slave-svc:8080/geoserver/wms>>?</url>
>      >      </http>
>      >      <timeout>10</timeout>
>      >      <connection_timeout>3</connection_timeout>
>      >        </source>
>      >
>      >      <tileset name="mtg_fd:ir105_hrfi">
>      >          <source>mtg_fd:ir105_hrfi</source>
>      >          <cache>multitier-cache</cache>
>      >          <grid
>     use_wms_intermediate_resolutions="true">EPSG4326_512</grid>
>      >          <grid
>     use_wms_intermediate_resolutions="true">EPSG3995_512</grid>
>      >          <grid
>     use_wms_intermediate_resolutions="true">EPSG3857_512</grid>
>      >      <grid use_wms_intermediate_resolutions="true">EPSG3976_512</
>     grid>
>      >          <dimensions>
>      >              <dimension type="regex" name="TIME" default="now">
>      >                  <regex>^.*$</regex>
>      >              </dimension>
>      >          </dimensions>
>      >          <format>MIXED</format>
>      >          <metatile>1 1</metatile>
>      >          <metabuffer>10</metabuffer>
>      >          <expires>604800</expires>
>      >      </tileset>
>      > ...
>      >
>      > Do you have any suggestions?
>      >
>      > --
>      >
>      > Regards, Alessandro Parma == GeoServer Professional Services from
>     the
>      > experts! Visit http://goo.gl/it488V <http://goo.gl/it488V>
>     <http://goo.gl/it488V <http://goo.gl/it488V>> for more
>      > information. == Alessandro Parma Technical Lead / Senior DevOps
>     Engineer
>      > GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) Italy
>      > phone: +39 340 4752467 fax: +39 0584 1660272
>      > https://www.geosolutionsgroup.com <https://
>     www.geosolutionsgroup.com> <https://www.geosolutionsgroup.com
>     <https://www.geosolutionsgroup.com>>
>      > https://twitter.com/geosolutions_it <https://twitter.com/
>     geosolutions_it>
>      > <https://twitter.com/geosolutions_it <https://twitter.com/
>     geosolutions_it>>
>      > ------------------------------------------------------- Con
>     riferimento
>      > alla normativa sul trattamento dei dati personali (Reg. UE
>     2016/679 -
>      > Regolamento generale sulla protezione dei dati “GDPR”), si
>     precisa che
>      > ogni circostanza inerente alla presente email (il suo contenuto, gli
>      > eventuali allegati, etc.) è un dato la cui conoscenza è riservata
>     al/i
>      > solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è
>      > giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è
>      > illecita. Le sarei comunque grato se potesse darmene notizia.
>     This email
>      > is intended only for the person or entity to which it is
>     addressed and
>      > may contain information that is privileged, confidential or
>     otherwise
>      > protected from disclosure. We remind that - as provided by European
>      > Regulation 2016/679 “GDPR” - copying, dissemination or use of this
>      > e-mail or the information herein by anyone other than the intended
>      > recipient is prohibited. If you have received this email by mistake,
>      > please notify us immediately by telephone or e-mail.
>      >
>      >
>      > _______________________________________________
>      > MapServer-users mailing list
>      > MapServer-users at lists.osgeo.org <mailto:MapServer-
>     users at lists.osgeo.org>
>      > https://lists.osgeo.org/mailman/listinfo/mapserver-users
>     <https://lists.osgeo.org/mailman/listinfo/mapserver-users>
> 
>     _______________________________________________
>     MapServer-users mailing list
>     MapServer-users at lists.osgeo.org <mailto:MapServer-users at lists.osgeo.org>
>     https://lists.osgeo.org/mailman/listinfo/mapserver-users <https://
>     lists.osgeo.org/mailman/listinfo/mapserver-users>
> 
> 
> 
> -- 
> 
> Regards, Alessandro Parma == GeoServer Professional Services from the 
> experts! Visit http://goo.gl/it488V <http://goo.gl/it488V> for more 
> information. == Alessandro Parma Technical Lead / Senior DevOps Engineer 
> GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) Italy 
> phone: +39 340 4752467 fax: +39 0584 1660272 https:// 
> www.geosolutionsgroup.com <https://www.geosolutionsgroup.com> https:// 
> twitter.com/geosolutions_it <https://twitter.com/geosolutions_it> 
> ------------------------------------------------------- Con riferimento 
> alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - 
> Regolamento generale sulla protezione dei dati “GDPR”), si precisa che 
> ogni circostanza inerente alla presente email (il suo contenuto, gli 
> eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i 
> solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è 
> giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è 
> illecita. Le sarei comunque grato se potesse darmene notizia. This email 
> is intended only for the person or entity to which it is addressed and 
> may contain information that is privileged, confidential or otherwise 
> protected from disclosure. We remind that - as provided by European 
> Regulation 2016/679 “GDPR” - copying, dissemination or use of this e- 
> mail or the information herein by anyone other than the intended 
> recipient is prohibited. If you have received this email by mistake, 
> please notify us immediately by telephone or e-mail.
> 




More information about the MapServer-users mailing list