Question re: PostGIS and MapScript getExtent() function

Paul Ramsey pramsey at REFRACTIONS.NET
Tue Jul 12 10:49:55 EDT 2005


msPOSTGISLayerGetExtent() is potentially extremely inefficient,  
depending on how it is implemented, so I would have to see your patch  
to judge if it does more harm than good. It may be doing good things  
for you and bad things for others.  One thing it *could* do without  
harm is read the wms_extent meta-parameter and use that if it is  
provided by the user.  There are also a few version specific fast  
extent functions available in PostGIS, but they are not guaranteed to  
work in all cases, at all times, correctly.

On 12-Jul-05, at 2:58 AM, Steve Hall wrote:

> Hi All,
>
> I'm using MapServer 4.6.0 with Oracle Spatial and PostGIS data  
> sources via PHP/MapScript.  Part of my application code looks like  
> this  pseudo-code :
>
>     $map->setLayerFilter("ThematicData", "REQUEST_ID=121");
>     $map->zoomToLayer("ThematicData");
> Here i'm setting a specific FILTER expression for a layer, and then  
> zooming to the extent of the (now filtered) layer.  I use the  
> layerObj->getExtent() and then mapObj->setExtent() functions to  
> achieve this behind the scenes.  This works great for Oracle, the  
> query is fast and makes for nice, tidy code in my application  
> without the need for Oracle specific SQL statements to derive the  
> new extent.
>
> However when I try this on PostGIS I just get a massive (useless)  
> extent returned.  Digging into the code I can see that the  
> msPOSTGISLayerGetExtent() function in mappostgis.c is effectively  
> doing nothing although a lot of code is commented out.
>
> Working on my local code I have re-enabled this code, fixed the  
> compilation errors and changed it so that when a FILTER is applied  
> to the layer this is used as part of the SQL call to PG.  It seems  
> to work great (from PHP/MapScript) and performance is fine and is  
> really useful for me meaning I don't need to calculate the extents  
> for a map myself - MapServer can supply the information in a  
> generic and abstract fashion.
>
> Ideally I would like to get this code fed back into MapServer, but  
> of course only if it's acceptable to you all.  So,  should I  
> instead post this to mapserver-dev or can I pass on the new code to  
> someone from here?
>
> There may be good, historical, reasons why this wasn't ever  
> implemented though so please let me know!
>
> Many thanks,
>
> Steve Hall
>
>



More information about the mapserver-users mailing list