[Mapserver-users] Mapserver layer open/close/query against PostGIS layers

Vinko Vrsalovic vinko at cprsig.cl
Fri Mar 26 17:26:24 EST 2004


Hi,

	I'm trying to use one unified query system against two types of
	layers, that is shapefiles and postgis layers. So far, the
	following code, which works just fine for shapefiles doesn't 
	work for PostGIS layers.

	The code:
        @$map->queryByRect($pt);
        for ($i=0;$i<$map->numlayers;$i++) {
                @$lyr = $map->getLayer($i);
                        if ($lyr->type == MS_LAYER_POLYGON || $lyr->type == MS_LAYER_POINT || $lyr->type == MS_LAYER_LINE) {
                                $lyr->open();
                                for ($j=0;$j<$lyr->getNumResults();$j++) {
                                        $cmo = $lyr->getResult($j);
                                        $shp = $lyr->getShape($cmo->tileindex,$cmo->shapeindex);
                                        $this->result[$lyr->name][$j] = $shp;
                                }
                                $lyr->close();
                        }
                }
        }
        return $this->result;	

	The versions:
	mapserver 4.0.1
	PHP 4.3.2
	Postgis 0.8
	PostgreSQL 7.4

	The error, which occurs when executing the above code:
	Fri Mar 26 17:47:52 2004 - msPOSTGISLayerGetShape(): Query
	error. Error executing POSTGIS  SQL   statement (in FETCH ALL):
	DECLARE m
	ycursor BINARY CURSOR FOR SELECT
	gid::text,rol_emap::text,fecha::text,hora::text,rol_geom::text,asbinary(force_collection(force_2d(g
	eom)),'NDR') from geom_predios WHERE OID = 9333379
	-ERROR:  cursor "mycursor" already exists

	<br>More Help:<br>Error with POSTGIS data variable. You
	specified ''.<br>
	Standard ways of specifiying are : <br>
	(1) 'geometry_column from geometry_table' <br>
	(2) 'geometry_column from (&lt;sub query&gt;) as foo using
	unique &lt;column name&gt; using SRID=&lt;srid#&gt;' <br><br>

	Make sure you put in the 'using unique  &lt;column name&gt;' and
	'using SRID=#' clauses in.

	<br><br>For more help, please see
	http://postgis.refractions.net/documentation.php

	<br><br>Mappostgis.c - version of June 12/2003.


-- 
Vinko Vrsalovic <el[|- at -|]vinko.cl>
http://www.cprsig.cl



More information about the mapserver-users mailing list