AnsweredAssumed Answered

Spatial query always return an empty array of features

Question asked by greenkarmic on Aug 6, 2013
Latest reply on Aug 6, 2013 by vinaybansal
Hi,

I've been stuck on this issue since yesterday, I'm stumped.

My source data is in the geographic coordinate system and my map is in web mercator. What I'm doing is creating a buffer around a point using a geometry service, then using that geometry as input into a spatial query to find the features contained within this buffer zone. But no matter what geometry I try passing to my query, the server returns no features. There are no errors, neither in the HTTP response from the server nor in the ArcGIS Server Manager log for this map service. I know there are features within this buffer, why am I getting nothing?

Here are the two functions is my code involved in the query:

      displayBufferZone: function(){                    if (this.bufferGraphic !== null){             this.map.graphics.remove(this.bufferGraphic);          }                    if (this.addressGraphic !== null){                          var geometryService = new esri.tasks.GeometryService(config.geometryService.url);             var bufferParams = new BufferParameters();             bufferParams.geometries = [ this.addressGraphic.geometry ];             bufferParams.bufferSpatialReference = this.addressGraphic.geometry.spatialReference;             bufferParams.outSpatialReference = this.map.spatialReference;             bufferParams.distances = [ this.selectDistance.value ];             // 5km, 10km, 25km             bufferParams.unit = esri.tasks.GeometryService.UNIT_METER;              geometryService.buffer(bufferParams).then(lang.hitch(this, function geometryComplete(geometries){                 // 1. Display this buffer zone on the map                var symbol = new esri.symbol.SimpleFillSymbol();                symbol.setStyle = esri.symbol.SimpleFillSymbol.STYLE_SOLID;                symbol.setColor(new dojo.Color([255,255,255,0.4]));                symbol.outline = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,255,255,0.4]), 1);                 this.bufferGraphic = new esri.Graphic(geometries[0], symbol);                 this.map.graphics.add(this.bufferGraphic);                this.bufferGraphic.getDojoShape().moveToBack();                                // 2. Zoom to see the entire buffer                this.map.setExtent( this.bufferGraphic.geometry.getExtent() );              }), function geometryError(error){                alert("Erreur au niveau du service de geométrie [RP]: " + error.message);             });          }       },              onSearch: function(){            // 1. Find features within the buffer zone          var queryTask = new esri.tasks.QueryTask(config.mapService.url + "0");                            var query = new esri.tasks.Query();          query.geometry = this.bufferGraphic.geometry;          query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_WITHIN;          query.returnGeometry = true;          query.outSpatialReference = this.bufferGraphic.geometry.spatialReference;          query.outFields = ["*"];           queryTask.execute(query, lang.hitch(this, function queryComplete(featureSet){                          // 2. Publish results             connect.publish("featureSet", featureSet);                       }), function queryError(error){             alert("Erreur au niveau du service de cartographie [RP]: " + error.message);          });         }



From Firebug:

Geometry task

Params

bufferSR 102100
distances 25000
f json
geodesic false
geometries {"geometryType":"esriGeometryPoint","geometries":[{"x":-8404543.175283927,"y":5868946.720327855,"spatialReference":{"wkid":102100}}]}
inSR 102100
outSR 102100
unionResults false
unit 9001

Response

{"geometries":[{"rings":[[[-8404543.1752839275,5893946.7203278551],[-8403549.2624065038,5893926.955258538],[-8402556.9211096354,5893867.6913032224],[-8401567.7204888798,5893769.022170404],[-8400583.224673748,5893631.1038762638],[-8399604.9903544784,5893454.1544979708],[-8398634.5643206052,5893238.4538288657],[-8397673.4810151514,5892984.3429360408],[-8396723.2601083722,5892692.2236210499],[-8395785.404094832,5892362.5577845732],[-8394861.3959176615,5891995.8666...
0.9464730229,5892362.5577845732],[-8412363.0904594827,5892692.2236210499],[-8411412.8695527036,5892984.3429360408],[-8410451.7862472497,5893238.4538288657],[-8409481.3602133766,5893454.1544979708],[-8408503.1258941088,5893631.1038762638],[-8407518.6300789751,5893769.022170404],[-8406529.4294582196,5893867.6913032224],[-8405537.0881613512,5893926.955258538],[-8404543.1752839275,5893946.7203278551]]]}]}

Query task

Params

f json
geometry {"rings":[[[-8404543.175283927,5893946.720327855],[-8403549.262406504,5893926.955258538],[-8402556.921109635,5893867.691303222],[-8401567.72048888,5893769.022170404],[-8400583.224673748,5893631.103876264],[-8399604.990354478,5893454.154497971],[-8398634.564320605,5893238.453828866],[-8397673.481015151,5892984.342936041],[-8396723.260108372,5892692.22362105],[-8395785.404094832,5892362.557784573],[-8394861.395917661,5891995.866696061],[-8393952.6966237...
50193,5891995.866696061],[-8413300.946473023,5892362.557784573],[-8412363.090459483,5892692.22362105],[-8411412.869552704,5892984.342936041],[-8410451.78624725,5893238.453828866],[-8409481.360213377,5893454.154497971],[-8408503.125894109,5893631.103876264],[-8407518.630078975,5893769.022170404],[-8406529.42945822,5893867.691303222],[-8405537.088161351,5893926.955258538],[-8404543.175283927,5893946.720327855]]],"spatialReference":{"wkid":102100}}
geometryType esriGeometryPolygon
inSR 102100
outFields *
outSR 102100
returnGeometry true
spatialRel esriSpatialRelWithin

Response:

{"displayFieldName":"Nom_ETAB","fieldAliases":{"FID":"FID","Id_ETAB":"Id_ETAB","Code_ETAB":"Code_ETAB","Nom_ETAB":"Nom_ETAB","codeTxt":"codeTxt","secteur":"secteur"},"geometryType":"esriGeometryPoint","spatialReference":{"wkid":102100,"latestWkid":3857},"fields":[{"name":"FID","type":"esriFieldTypeOID","alias":"FID"},{"name":"Id_ETAB","type":"esriFieldTypeDouble","alias":"Id_ETAB"},{"name":"Code_ETAB","type":"esriFieldTypeDouble","alias":"Code_ETAB"},{"name":"Nom_ETAB","type":"esriFieldTypeString","alias":"Nom_ETAB","length":254},{"name":"codeTxt","type":"esriFieldTypeString","alias":"codeTxt","length":10},{"name":"secteur","type":"esriFieldTypeString","alias":"secteur","length":10}],"features":[]}


Thanks

Outcomes