|
|
|
Vitor Fortunato
|
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 [hidden email] http://lists.osgeo.org/mailman/listinfo/fusion-users |
||||||||||||||||
|
Paul Spencer-2
|
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 > [hidden email] > http://lists.osgeo.org/mailman/listinfo/fusion-users __________________________________________ Paul Spencer Chief Technology Officer DM Solutions Group Inc http://www.dmsolutions.ca/ _______________________________________________ fusion-users mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/fusion-users |
||||||||||||||||
|
Vitor Fortunato
|
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 <[hidden email]> wrote: Vitor, _______________________________________________ fusion-users mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/fusion-users |
||||||||||||||||
|
Tom Lazo / Stygy
|
Hi Vitor,
I have a problem here. I use Fusion with MapServer and i'm trying to filter some features from a layer with this code: options.maxFeatures = 0; options.layers = 'LOTES'; options.filter = 'ID_FICHA = 193'; this.getMap().query(options); But it paints me the entire map when it's suppose just to paint the feature with the id = 193. I've changed the Query.php just like you did, but noth. Please tell me where is my mistake. Thanks Tom
Stygy is not a living being! |
||||
|
Tom Lazo / Stygy
|
I got it! xD
options.selectionType = 'INTERSECTS'; options.maxFeatures = 0; //options.computed = this.bComputeMetadata; options.layers = 'LOTES'; options.extendSelection = true; //options.computed = false; options.filter = '([ID_FICHA] = '+ idFicha + ' )'; this' the right way :D. I'd missed the '(' Thanks
Stygy is not a living being! |
||||||||||||||||
| Free Embeddable Forum Powered by Nabble | Help |