[mapserver-users] Dynamically generating map extents WITHOUT MapScript or templating using shp2img (or mapserv)

Matthew Pettis matthew.pettis at gmail.com
Fri Jan 7 22:31:09 EST 2011


Hi,

I'd like to query my PostGIS database for a polygon and then create a
.png file based on that polygon with the polygon's max extent with the
'shp2img' tool.  I'm likely to change the query frequently to find
different polygons, and would like MapServer to automatically
calculate the extent based on the result query so I don't have to run
a separate query to find the extent of that polygon and hardcode it
into the EXTENT directive for the given query.

I see in the documentation at http://mapserver.org/mapfile/map.html
that this should be possible:
---
EXTENT [minx] [miny] [maxx] [maxy]
The spatial extent of the map to be created. In most cases you will
need to specify this, although MapServer can sometimes (expensively)
calculate one if it is not specified.
---

However, I cannot find an example of how to do this.  I have a working
mapfile with an EXTENT value I've looked up, and when I use it, it
works fine.  I thought the natural thing to do would be to just
comment out the 'EXTENT' directive in the MAP section, but that gave
me an error.  Could someone point me to how to make this work?

OS: Ubuntu 8.04 LTS
Mapserver version: MapServer version 5.4.2 OUTPUT=GIF OUTPUT=PNG
OUTPUT=JPEG OUTPUT=WBMP OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=FREETYPE
SUPPORTS=ICONV SUPPORTS=WMS_SERVER SUPPORTS=FASTCGI INPUT=EPPL7
INPUT=JPEG INPUT=POSTGIS INPUT=SHAPEFILE

Thanks in advance,
Matt


More information about the mapserver-users mailing list