AnsweredAssumed Answered

Query with SPATIAL_REL_WITHIN does not return any results

Question asked by vygintasc on Nov 16, 2015
Latest reply on Dec 14, 2015 by vygintasc

I have a map service which contains a number of polygons. I am looking to get two different sets of results:

 

  • All polygons which are fully contained within an extent
  • All polygons which are intersected by an extent.

 

To achieve this I am using following code:

 

var containedProjQuery = new Query();
var containedProjQueryTask = new QueryTask(configuration.documentParams.ProjectMapService);
containedProjQuery.spatialRelationship = Query.SPATIAL_REL_WITHIN;
containedProjQuery.returnGeometry = true;
containedProjQuery.outFields = ["PROJ_NAME"];
containedProjQuery.geometry = aoiExtent;
var containedProjects = containedProjQueryTask.execute(containedProjQuery);

var intersectingProjQuery = new Query();
var intersectingProjQueryTask = new QueryTask(configuration.documentParams.ProjectMapService);
intersectingProjQuery.spatialRelationship = Query.SPATIAL_REL_INTERSECTS;
intersectingProjQuery.returnGeometry = true;
intersectingProjQuery.outFields = ["PROJ_NAME"];
intersectingProjQuery.geometry = aoiExtent;
var intersectingProjects = intersectingProjQueryTask.execute(intersectingProjQuery);

var promises = All([containedProjects, intersectingProjects]);
promises.then(returnResults);

 

The issue I'm running into is that the SPATIAL_REL_WITHIN query always returns 0 results, while SPATIAL_REL_INTERSECTS appears to work correctly. Is there something I'm missing?

Outcomes