[postgis-users] reusing MapServer query-string

Paul Ramsey pramsey at refractions.net
Thu Jul 25 08:17:12 PDT 2002


Sort answer, no. 
Longer answer, there are a bunch of PHP-specific enhancements which
would make Mapscript/Database interactions alot more efficient. For
example, being able to hand an existing PHP connection resource to
mapscript when it creates a map object, so save the overhead of
constanding re-initializing the connection. For Oracle in particular,
which has a criminally large connection overhead, this would be quite
important. However, all these changes require both some moderate
jimmying with the mapserver source as well as with the PHP interface, so
it is not a 2 hour hack. :/
Paul

Jan Hartmann wrote:
> 
> 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
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users




More information about the postgis-users mailing list