querybypoint Postgis

Gregory S. Williamson gsw at GLOBEXPLORER.COM
Fri May 12 18:59:43 EDT 2006


Bertsch --

I am not conversant with the php side of things, but I do wonder about the connection string.

DATA "the_geom FROM
  (SELECT the_geom from mus where longitudecenter <> 0
    AND NAME = 'USAR-0')
 AS myquery USING UNIQUE the_geom using SRID = -1"

Try selecting another column as well as the_geom to use as the UNIQUE part. MMS needs to have a unique identifier for each row, and asking for unique geometries is odd ... in versions of postgres which have the OIDs included in the tables you could say "USING UNIQUE oid USING SRID = -1"; if your table has its own unique identifier for each row that would be preferable.

The postgis manual for 1.x says that MMS needs to have a proper unique column to do queries. Note also:
"Warning
The parser for Mapserver PostGIS layers is fairly primitive, and is case sensitive in a few areas. Be careful to
ensure that all SQL keywords and all your USING clauses are in upper case, and that your USING UNIQUE
clause precedes your USING SRID clause."

Presumably NAME is indexed so this query will be fast, but in general spatial queries won't use the GIST index if there is no "&&" operator in use.

HTH,

Greg Williamson
DBA
GlobeXplorer LLC


-----Original Message-----
From:	UMN MapServer Users List on behalf of Bertsch
Sent:	Fri 5/12/2006 3:39 PM
To:	MAPSERVER-USERS at LISTS.UMN.EDU
Cc:	
Subject:	[UMN_MAPSERVER-USERS] querybypoint Postgis

Hi list

I have a little problem with my application. I have several different
layers(shapefile) furthermore, I have points stored in a PostGIS database.
Every thing works fine except the querying of points in the database, it
shows me always a result but there seems to be nothing in the resultset, at
least the shapeindex of the result is always 1. With points from a shapefile
it works but not for points in PostGIS, i have to add something special?
Maybe the code is not correct, but remind with normal shape files it is
functioning very well.
Thanks anyway,

------------------------------------------------------------------
MAPFILE

LAYER 
		NAME fincas
		TYPE POINT
		CONNECTIONTYPE postgis
		CONNECTION "dbname=........"
		DATA "the_geom FROM (SELECT the_geom from mus where longitudecenter <> 0
AND NAME = 'USAR-0') AS myquery USING UNIQUE the_geom using SRID = -1"
		STATUS ON
		TOLERANCE 4
		METADATA
			"DESCRIPTION" "farms"
			"RESULT_FIELDS" "f_code" 
			"TABLE_NAME" "public.mus" # i need that?
		END
		
		CLASS
			NAME "farms"
			TEMPLATE "Dummy"
			STYLE
				SYMBOL "POINT"
				COLOR 192 192 192
				SIZE 8
			END
		END
	END
------------------------------------------------------------------
PHP code
$other_point->setXY($x,$y);  //x and y are longitude and latitude
$map->querybyPoint($other_point,MS_MULTIPLE,-1);
$layer = $map->getLayerByName('farms');
	echo("<br>".$layer->getNumResults()); // i get an result
$layer->open();
$selFields = explode(" ", $layer->getMetaData("RESULT_FIELDS"));
$oRes = $layer->getResult(0);

echo($oRes->tileindex." ".$oRes->shapeindex." ".$oRes->classindex); //
always -1 1 0
	if($layer->getNumResults() != 0){
		$oShape = $layer->getShape($oRes->tileindex,$oRes->shapeindex);
		$ID = $oShape->values['f_code'];
		$oShape->free(); //ERROR Call to a member function on a non-object
	}

--
View this message in context: http://www.nabble.com/querybypoint-Postgis-t1610695.html#a4366731
Sent from the Mapserver - User forum at Nabble.com.

!DSPAM:44650eb6237721804284693!



More information about the mapserver-users mailing list