[fusion-users] Problems using map.query() method

Vitor Fortunato sapucaiatotal at gmail.com
Thu Jun 5 14:43:40 EDT 2008


I made it!

I've just change the line
if (@$oLayer->queryByShape($oSpatialFilter) == MS_SUCCESS) {
for
if (@$oLayer->queryByAttributes($field, $filter, MS_MULTIPLE) == MS_SUCCESS)
{

where:
- $field is the item (attribute) on wich the query is performed;
- $filter is the expression
- MS_MULTIPLE allow to selection of all records returned (use MS_SINGLE to
select only the first record)
Ex.: queryByAttributes('gid', 'gid in (1, 2, 3)', MS_MULTIPLE)

I am a little bit confused about the $field parameter, because I can set it
to be any field of the layer, it don't affects the query. But I have to set
a valid field of the layer...
in the $filter parameter I can use any "where" expression supported by
PostGIS (st_intersects, st_area, in, and, like ...)
I am using a mapfile pointing to tables in PostGIS..


-----

PS.: I don't known how to call queryByShape and queryByAttributes at the
same time and combine the results!

Reference of the queryByAttributes method:
http://mapserver.gis.umn.edu/docs/reference/phpmapscript-class/classes/layerobj


Best Regards
Vitor Fortunato




On Sat, May 31, 2008 at 9:30 PM, Paul Spencer <pspencer at dmsolutions.ca>
wrote:

> Vitor,
>
> you are not doing anything wrong, the mapserver code for the query()
> function just hasn't been updated to use the filter value in Query.php
> (although it does parse it from the request parameters).
>
> Patches welcome :)
>
> Cheers
>
> Paul
>
>
> On 29-May-08, at 6:03 AM, Vitor Fortunato wrote:
>
>  I am having problems to use the map.query() method to filter attributes.
>> In this method you can send a SQL filter inside the options parameter.
>> But it didn't works for me...
>>
>> I think the query method is ignoring this parameter.
>>
>> I've found the code bellow in the query.php file, and it seems that this
>> file is not using the filter parameter...
>> The code bellow, shows only the queryByShape using the $oSpatialFilter
>> parameter...
>>
>>
>> /// ... ... ... >>>>>>>>>>>>>>>>>>>>>>>>>>>
>>
>> if (@$oLayer->queryByShape($oSpatialFilter) == MS_SUCCESS) {
>>        $result->hasSelection = true;
>>        $layerName = $oLayer->name;
>>        array_push($result->layers, $layerName);
>>        $result->$layerName->featureCount = $oLayer->getNumResults();
>>        //TODO: dump out the extents of the selection
>>    }
>>
>> /// >>>>>>>>>>>>>>>>>>>>>>>>>>> ... ... ...
>>
>>
>>
>>
>> I have a simple widget that uses the following code:
>>
>> execute : function() {
>>    var options = {};
>>    options.selectionType = 'INTERSECTS';
>>    options.geometry = "POLYGON((-75.58840579710144 -10.755072463768112,
>> -61.16086956521739 -10.755072463768112, -61.16086956521739
>> 0.005797101449276809, -75.58840579710144 0.005797101449276809,
>> -75.58840579710144 -10.755072463768112))";
>>    options.maxFeatures = 0;
>>    options.filter = "gid=1"
>>    options.layers = 'States';
>>
>>    this.getMap().query(options);
>> }
>>
>>
>> the polygon intersects with 5 states, but I would like to select just the
>> state with 'gid = 1', using the filter option.
>> My code select the 5 states that intersect with the polygon and don't
>> apply the filter.
>>
>> What I am doing wrong?
>>
>> _______________________________________________
>> fusion-users mailing list
>> fusion-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/fusion-users
>>
>
>
> __________________________________________
>
>   Paul Spencer
>   Chief Technology Officer
>   DM Solutions Group Inc
>   http://www.dmsolutions.ca/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/fusion-users/attachments/20080605/9b80eb01/attachment.html


More information about the fusion-users mailing list