[postgis-users] reusing MapServer query-string

Jan Hartmann jhart at frw.uva.nl
Thu Jul 25 06:37:07 PDT 2002


Is it possible to reuse a PostGIS query for Mapserver within PHP-MapScript,
once the map has been created? The usual way to create a map layer from
Postgis is:

$layer->set("connectiontype","POSTGIS");
$layer->set("connection","host = ... port=... etc");
$layer->set("data","the_geom from table");

This works fine, even with complex subselects within the DATA-step, like:
"the geom from
    (select table1.the_geom, table1.datavar from table1,table2
        where (distance(table1.the_geom,table2.the_geom)) = 0
        and table1.linkvar = table2.linkvar
     )
"

This wil produce a map with only the elements of table1 that are overlapping
with elements of table2 (very nice indeed!). I can even use the values of
"datavar" to create classes within Mapserver, like

$class->setexpression("[datavar] >= $value1 and [datavar] < $value2");

which will color the map-selection the way I want.

This already offers very advanced mapping capabilities, especially since
"datavar" can alo be retrieved from a subselect. However, I would like to
reuse the query-results for "datavar", e.g. to produce statistics. I can of
course rerun the query from within PHP, but this takes time and is
essentially redundant. As far as I understand the code in "mappostgis.c", a
cursor is created for the query; would it by any means be possible to return
this cursor to the calling PHP-application?


Jan Hartmann
Department of Geography
University of Amsterdam
jhart at frw.uva.nl





More information about the postgis-users mailing list