[mapserver-users] Mapcache with mapfile as layer

Pablo Cecconi pc at educ.ar
Fri Sep 20 12:06:29 PDT 2013


Well, I actually made it work! Took me a while to compile Mapcache with
Mapserver support but when I finally managed to do it the rest was easy
enough.
So, here's what you have to do if you want to use Mapcache with Mapfiles
directly though the CGI protocol instead of WMS:

1) Compile Mapcache with Mapserver support using these options:

cmake -DMAPSERVER_LIBRARY="/usr/lib/i386-linux-gnu/libmapserver-6.2.1.so"
-DWITH_MAPSERVER=1 ..

I did this on Debian Wheezy. Obviously you'd have to change the mapserver
library path according to your particular distribution.

2) Install Mapcache following the instructions provided in the INSTALL file
and add a block like the following to enable a Mapfile source on your setup:

<source name="mapabsas" type="mapserver">
      <http>
         <url>http://localhost/cgi-bin/mapserv?</url>
      </http>
      <mapfile>/path/to/your/mapfile.map</mapfile>
</source>

That's it! No need to specify layers or anything else. Everything can be
controlled through the settings in the mapfile so unless you want to add a
new mapfile to your service there's no need to touch Mapcache configuration
at all.

Cheers!
Pablo



On Thu, Sep 19, 2013 at 11:24 PM, Pablo Cecconi <pc at educ.ar> wrote:

> Well, maybe I'm not getting it right but it seems to me that this file:
>
> https://github.com/mapserver/mapcache/blob/master/lib/source_mapserver.c
>
> and this example in the
> https://github.com/mapserver/mapcache/blob/master/mapcache.xml.sample:
>
>   <source name="osm" type="wms">
>       <http>
>          <url>http://localhost/cgi-bin/mapserv?</url>
>       </http>
>       <getmap>
>          <params>
>             <FORMAT>image/png</FORMAT>
>             <LAYERS>default</LAYERS>
>             <!--<MAP>/Users/tbonfort/dev/mapserver-utils/empty.map</MAP>-->
>             <MAP>/Users/tbonfort/dev/mapserver-utils/osm-google.map</MAP>
>          </params>
>       </getmap>
>    </source>
>
> would suggest that, although not documented, mapcache might be able to
> talk to mapserver through the cgi protocol if built with the USE_MAPSERVER
> flag. I can't wait to test it!
>
>
>
> On Thu, Sep 19, 2013 at 11:08 PM, Stephen Woodbridge <
> woodbri at swoodbridge.com> wrote:
>
>> Thanks, I would be interested in hearing how you work this out. It might
>> help to remember that mapcache ONLY talks to mapserver via the WMS
>> protocol, NOT the mapserver CGI protocol. This is a big difference from
>> TileCache. Anyway good luck with your efforts.
>>
>> -Steve
>>
>>
>> On 9/19/2013 10:00 PM, Pablo Cecconi wrote:
>>
>>> The problem is not the invalidation of the tiles (which is a very simple
>>> step that can even be done with a simple bash script) but the need to
>>> list every single layer with status ON on the mapfile. To do that
>>> automatically we need to use mapscript (as TileCache does) but we also
>>> need to deal with generating a valid mapcache config file (which we
>>> cannot do with mapscript). With TileCache instead we just mapped a given
>>> layer name with a mapfile and we only had to care about invalidating and
>>> reseeding of tiles and not with modifying TileCache config file. It's
>>> not so bad though. I just thought that being part of Mapserver maybe
>>> MapCache could have some kind of "special integration" with it.
>>> Anyway, I'll continue digging to see if I find some easier way to deal
>>> with this particular problem and if I do I promise to let you know.
>>> Thanks again.
>>>
>>> Pablo
>>>
>>>
>>>
>>> On Thu, Sep 19, 2013 at 10:18 PM, Stephen Woodbridge
>>> <woodbri at swoodbridge.com <mailto:woodbri at swoodbridge.**com<woodbri at swoodbridge.com>>>
>>> wrote:
>>>
>>>     Try it, it might work, I don't remember, but you still have the
>>>     problem of invalidating the tiles when you changes the mapfile. But
>>>     seriously, your approach seems a little haphazard. Also how often to
>>>     you make mapfile changes? how did you deal with the invalidating
>>>     cache problem before?
>>>
>>>     The big difference here is that mapcache is using mapserver as a WMS
>>>     source and therefore it has to conform to the WMS rules.
>>>
>>>     Anyway, Thomas is the one that you would need to convince or fund if
>>>     you want changes to the existing behavior. Meanwhile it would be
>>>     worthwhile your time to figure out how it curently works before
>>>     asking for features that might already exist. It has been a few
>>>     months since I setup a mapcache instance and I know there have been
>>>     changes that I'm not on top of in the newest  release.
>>>
>>>     -Steve
>>>
>>>
>>>     On 9/19/2013 3:46 PM, Pablo Cecconi wrote:
>>>
>>>         The problem with that approach is that is the mapfile changes (a
>>>         layer
>>>         is added or the default status of a layer changes) then I also
>>>         have to
>>>         update mapcache config file. What i wonder is if there is a way
>>>         to just
>>>         modify the map and have Mapcache reflecting that change.
>>>
>>>         Pablo
>>>
>>>
>>>         On Thu, Sep 19, 2013 at 4:40 PM, Stephen Woodbridge
>>>         <woodbri at swoodbridge.com <mailto:woodbri at swoodbridge.**com<woodbri at swoodbridge.com>
>>> >
>>>         <mailto:woodbri at swoodbridge.__**com
>>>
>>>         <mailto:woodbri at swoodbridge.**com <woodbri at swoodbridge.com>>>>
>>> wrote:
>>>
>>>              On 9/19/2013 3:02 PM, Pablo Cecconi wrote:
>>>
>>>                  Hello,
>>>
>>>                  I've been a Mapserver user for many years now but I'm
>>>         new to
>>>                  Mapcache
>>>                  and I'm not sure whether it's possible to replicate a
>>>         particular
>>>                  TileCache setup using Mapcache.
>>>                  What we have today is a number of mapfiles (with
>>>         Mapserver 5.4)
>>>                  set up
>>>                  as WMS-C layers served with TileCache. We're migrating
>>>         to Mapserver
>>>                  6.2.1 and as it's incompatible with TileCache we expect
>>>         to be
>>>                  able to
>>>                  replace it using Mapcache.
>>>                  In our current setup if I have a mapfile where a
>>> particular
>>>                  layer has
>>>                  STATUS OFF then TileCache will honor that status and
>>>         not render
>>>                  the layer.
>>>                  I'd like to know whether it's possible to have MapCache
>>>         work
>>>                  that way,
>>>                  that is, passing the map name as the LAYERS parameter
>>>         of the WMS
>>>                  service
>>>                  and make it honor whatever STATUS a particular layer
>>>         would have
>>>                  in the
>>>                  mapfile.
>>>
>>>
>>>              I think the mapcache paradigm for this in mapcache works
>>>         like this:
>>>
>>>              tileset
>>>                 name=foo
>>>                 source=foo-source
>>>
>>>              source
>>>                 name=foo-source
>>>                 map=/path/to/mapfile
>>>                 layers=layer1,layer2,layers3,.**____..
>>>
>>>
>>>
>>>              So you can configure which layers a tileset returns. I'm
>>>         not sure
>>>              how it deals with the status off, but it will work if you
>>>         define the
>>>              list explicitly. This also allow you to do this in the same
>>>         mapcache.xml
>>>
>>>              tileset
>>>                 name=foo2
>>>                 source=foo-source2
>>>
>>>              source
>>>                 name=foo-source2
>>>                 map=/path/to/mapfile
>>>                 layers=streets,...
>>>                 transparent=true
>>>
>>>              I do this a lot when I have a subset of data like streets
>>>         that I
>>>              want to render as an overly on a raster image
>>>
>>>              -Steve W
>>>              ______________________________**_____________________
>>>              mapserver-users mailing list
>>>              mapserver-users at lists.osgeo.__**__org
>>>              <mailto:mapserver-users at lists.**__osgeo.org
>>>         <mailto:mapserver-users at lists.**osgeo.org<mapserver-users at lists.osgeo.org>
>>> >>
>>>         http://lists.osgeo.org/____**mailman/listinfo/mapserver-___**
>>> _users <http://lists.osgeo.org/____mailman/listinfo/mapserver-____users>
>>>         <http://lists.osgeo.org/__**mailman/listinfo/mapserver-__**users<http://lists.osgeo.org/__mailman/listinfo/mapserver-__users>
>>> >
>>>
>>>         <http://lists.osgeo.org/__**mailman/listinfo/mapserver-__**users<http://lists.osgeo.org/__mailman/listinfo/mapserver-__users>
>>>         <http://lists.osgeo.org/**mailman/listinfo/mapserver-**users<http://lists.osgeo.org/mailman/listinfo/mapserver-users>
>>> >>
>>>
>>>
>>>
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20130920/d3fd5855/attachment.html>


More information about the mapserver-users mailing list