[Mapserver-users] Mapscript drawQuery() on big PostGIS layers doesn't work properly ?

Daniel Faivre daniel.faivre at camptocamp.com
Wed Oct 15 07:02:32 EDT 2003


Hello,

I've encountered serious difficulties with "big drawQueries" after a 
queryByShape() on PostGIS layers, that do not happen with shapefiles.

Here is a sample php source code for problematics spatial queries with a 
postgis layer: the
drawQuery() after a queryByShape() is not efficient enough (see sample 
execution times commented in the code). Furthermore, tests shows that 
replacing $sl_thm2 by a postgis layer lead to increased computing delays.

I assume that querying PostGIS layers in mapserver 4 is not efficient 
enough ?

I've noticed comments in mapserver source code about an improved 
algorithm, yet not implemented.

My PostGIS layer is properly spatial-indexed, and I've also tried to add 
USING UNIQUE USING SRID="-1" without any improvement ...
_______________________________________________________________________________________________________
$Map = ms_newMapObj('my_mapfile.map');

$sl_thm1 = $Map->getlayerbyname('mybigpolygonslayer');      // A big 
polygons PostGIS layer
$sl_thm2 = $Map->getlayerbyname(myquerylayer');                 // A 
shapefile with one multiplygon

$sl_thm2->queryByRect($Map->extent);                                  
 // Necessary for queryByFeatures
       
$res = $sl_thm1->queryByFeatures($sl_thm2->index);
$num_results = $sl_thm1->getNumResults();

echo "nb find: ".$num_results;               // about 2000 items founds, 
in my sample

//$map_img = $Map->draw();                // 2  seconds to display the 
result
$map_img = $Map->drawQuery();        // 160 to 260 seconds for a postgis 
layer, 2  seconds for the same layer as shapefile !!!

$imgurl = $map_img->saveWebImage();

echo '<img src='.$imgurl.'>';
_______________________________________________________________________________________________________

What can I do ??? Have you experienced same difficulties with big 
postgis layers ? Any idea ? Workaround ?

Best regards,

-- 
Daniel Faivre
Ohceo - Camptocamp
+33 4 79 75 28 19
180 rue du Genevois
73000 Chambéry le Haut - FRANCE





More information about the mapserver-users mailing list