Mapscript query

Tamas Szekeres szekerest at GMAIL.COM
Tue Jul 24 18:30:40 EDT 2007


David,

We have a working (drawquery.cs) sample application in the SVN trunk
which does a similar job, by using the queryByAttributes though.

http://trac.osgeo.org/mapserver/browser/trunk/mapserver/mapscript/csharp/examples/drawquery.cs


You might try:

drawquery sample.map "('[countyid]'='67')" sample.png

I'm pretty sure that we are using a string comparison when evaluating
the expressions. So you might have to make sure about the exact match
between the actual field value and the constant have been used in the
expression. The method, how the values of the numeric fields are
converted the strings is somewhat data provider dependent.

Best regards,

Tamas



2007/7/23, David Hober <dhober at geographit.com>:
>
>
>
>
> Greetings,
>
>
>
> In part of developing an application, I am trying to get it to perform a
> query on a region, given certain constraints.  I've spent some time
> searching the MapServer forums and Google, and I still have not found an
> answer...
>
>
>
> I'm working with the C# mapscript library.
>
>
>
> It works as follows:
>
>
>
> A user sets up a filter for what they want returned in a search.  Then they
> determine the region over which to search (currently I have it only
> searching over a point and a tolerance level defined).  I pass the field to
> be filtered to the layer's filteritem property, and call the layer's
> setFilter method, and pass in the what it is the user wants to see.  As an
> example,
>
>
>
> layerObj ms_layer = map.getLayerByName("county");
>
> ms_layer.filteritem = "countyid"
>
> ms_layer.setFilter("[countyid] = 67");
>
>
>
> I then perform a queryByPoint query on the layer, which returns a MS_FAILURE
> value.  If I remove the call to ms_layer.filterItem, the query succeeds, but
> the results are not filtered.  I've tried a variety of string combinations
> in the setFilter(…) method, including the following:
>
>
>
> [countyid] = 67
>
> "[countyid] = 67"
>
> [countyid] = "67"
>
> ( [countyid] = 67 )
>
> [countyid] == 67
>
> "[countyid] == 67"
>
>
>
> … and so on and so forth.
>
>
>
> Just as a reference point, here's my call to the query…
>
>
>
> Ms_layer.queryByPoint(map, queryPoint, mapscript.MS_MULTIPLE, tolerance);
>
>
>
> I'll welcome any insights or theories on this matter.
>
>
>
> Thanks!
>
>
>
> -- Dave H



More information about the mapserver-users mailing list