schlot

Valid geometry types for Query, Can input polygon have a hole in it?

Discussion created by schlot on Mar 6, 2013
Latest reply on Mar 7, 2013 by JGravois-esristaff
I have a polygon layer I am using as a querytask based on regional boundaries.  The polygon layer is our state, cut into 5 large pieces.  The county where the state offices are is a region unto itself, called central, which is completely surrounded by northwest region.  I have verified that the northwest region does exclude this central region, so I would call this a polygon with a hole in it, or maybe a multipart polygon.

My problem is when I want to use the geometry of the northwest region polygon as input to a query and query task.  I'm first selecting the region from a pick list and determining the geometry.  This geometry is then used as input to a 2nd query task.

The callback function from the initial queryTask:
function showRegionResults (results) {
        region = results.features[0].geometry;
        map.setExtent(region.getExtent(), true);      
  findStaffInRegion(region);
    }


The 2nd query task which is populating a datagrid:

function findStaffInRegion(region) {
   var staffQueryTask = new esri.tasks.QueryTask(serverPathName + "/arcgis/rest/services/myService/MapServer/2"); //EUSstaff
   var staffQuery = new esri.tasks.Query;
   staffQuery.outFields = ["*"];
   if (region) {
   staffQuery.geometry = region;
   staffQuery.spatialRelationship = esri.tasks.Query.SPATIAL_REL_CONTAINS;
   staffQueryTask.execute(staffQuery);
   dojo.connect(staffQueryTask, "onComplete", function(results){
  var items = dojo.map(results.features, function(feature){
            return feature.attributes;
        });
        var data = {
                    identifier: "Contact_ContactId", //This field needs to have unique values
                    label: "ID", //Name field for display. Not pertinent to a grid but used elsewhere. 
                    items: items
                };
                //Create data store and bind to grid. 
                store = new dojo.data.ItemFileReadStore({
                    data: data
                });
                 var fp = dijit.byId('floater');
                        if (fp.style.visibility=="hidden") {
                            fp.style.visibility="";
                            fp.show();

                        }
                var staffGrid = dijit.byId('staffGrid');
                staffGrid.setStore(store);
                openFloatingPane();
       });
       }else{
           console.log("region variable not defined")
       }
}


This code works fine for all regions, except for the one that has the hole in it.  Is that type of polygon not a valid input geometry for a Query?  Am I misunderstanding what spatial relationship I should choose?  If I have to, I can run another function that excludes the features that are in the central region, but I'd rather not do that if I just have something wrong with this logic.

Outcomes