[Mapserver-users] querybyattributes with PostGIS layer

Map Surfers map_surfer at yahoo.com
Mon Oct 6 12:07:28 PDT 2003


Hello all,

I am using Mapserver 4.0 and Postgres/PostGIS running
on RedHat 9.0. I have no problems with PostGIS layers
as far as viewing or querying (by rect or point). I
created a "zoom to department" tool with the
querybyattributes function. Basically, it gets the the
shape objects bounds and zooms to that extent. It was
successful using shapefile layers. However when
replacing the shapefile layer with a PostGIS layer
this fuction fails.

The attribute I am querying is the "query" field in
the data base.


//DEBUG
print $oLayer->name //layer object is good
print $department   //returns a valid value
//no problems until
   if ($oLayer->queryByAttributes("query",
$department, MS_SINGLE) == MS_SUCCESS){
print "i'm in!";
}
else{
print "i'm not in.";
}

of course it returns "i'm not in."

This is the exact syntax I used with the shapefile
layer.  Does PHP/Mapscript support the
querybyattributes function with PostGIS layers.

Here excerpt for querybyattributes from the
mapserver4+ PHP/Mapscript README:
int queryByAttributes(string qitem, string qstring,
int mode)
        Query layer for shapes that intersect current
map extents.
        qitem is the item (attribute) on which the
query is performed, 
        and qstring is the expression to match.
        The query is performed on all the shapes that
are part of a CLASS 
        that contains a TEMPLATE value or that match
any class in a
        layer that contains a LAYER TEMPLATE value.  
        Note that the layer's FILTER/FILTERITEM are
ignored by this function.
        Mode is MS_SINGLE or MS_MULTIPLE depending on
number of results
        you want. 
        Returns MS_SUCCESS if shapes were found or
MS_FAILURE if nothing
        was found or if some other error happened
(note that the error 
        message in case nothing was found can be
avoided in PHP using 
        the '@' control operator).

Any clues would greatly be appreciated,
Damian


__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com



More information about the MapServer-users mailing list