queryByAttributes...

Sean Gillies sgillies at FRII.COM
Tue Apr 12 13:45:53 EDT 2005


On Apr 12, 2005, at 11:17 AM, Paul james wrote:

> I=B4m with problems using queryByAttributes... getResult(0) always
> return n=
> ull...
> any idea?
> ps.: using c#
>
> thx
>
> =20
>
> layer =3D mp.getLayerByName("layer");
> string value =3D "'[oid]' =3D '32141'";
> if ((layer.queryByAttributes(mp,"oid", value, 0))=3D=3D1)
> {
>       resultCacheMemberObj result =3D new resultCacheMemberObj();
>       result =3Dlayer.getResult(0);
> }
>
>

Is it just me, or is the listserv mangling this (and other) emails?

I'm assuming you are using MapServer 4.4.  First, of all, you should
generally compare integer results from mapscript to
mapscript.MS_SUCCESS (0) and mapscript.MS_FAILURE (1).  Second, I think
you really should be doing something like this:

     layerObj layer = mp.getLayerByName("layer");
     ...
     layer.queryByAttributes(...);
     resultCacheObj results = layer.getResults();
     if (results)
     {
         resultCacheMemberObj result = results.getResult(0);
     }

Keep in mind that the extents of your 'mp' map are used to filter
results.  If you query by attributes for a feature outside the map
extents, it will not be found.

cheers,
Sean

--
Sean Gillies
sgillies at frii dot com
http://users.frii.com/sgillies



More information about the mapserver-users mailing list