alex92190

Query results feature set to a brand new Features set

Discussion created by alex92190 on May 2, 2014
Latest reply on Jun 4, 2014 by alex92190
Hi all,
Here what I am trying to do:
1) My overall goal is to query an extent and to extract data by this extent. I can successfully achieve the first part.

2) Here is my issue: The Dynamic layer queried has a schema that wont work with the GP "Extract data". Here are the default fields I need, these fields are the default for any feature set created:

Fields:
FID ( type: esriFieldTypeOID , alias: FID )
Id ( type: esriFieldTypeInteger , alias: Id )
Shape_Length ( type: esriFieldTypeDouble , alias: Shape_Length )
Shape_Area ( type: esriFieldTypeDouble , alias: Shape_Area )
Features: None.


3) The solution that I am trying to implement is very close to what this person was trying to implement on this thread. My basic understanding of this is to gather all graphics, push them into a brand new feature set and then use it as an AOI.

4) My code that works but return an empty shapefile or values:

function executeQueryTask(county) {
    var county = document.getElementById("sel_county").value        
          var queryTask = new QueryTask("http://webgisdevint1/arcgis/rest/services/Alex_Try/Counties/MapServer/0");
    var query = new Query();
          query.returnGeometry = true;
          query.outFields = ["FMNAME_UC"];
          query.where = "FMNAME_UC = '" + county + "'";
          query.outSpatialReference = map.spatialReference;
    queryTask.execute(query);
    var clipLayers = [];
     if (registry.byId("layer1").get("checked")) {
               clipLayers.push("Counties");
            }
            if (registry.byId("layer2").get("checked")) {
               clipLayers.push("SRA");
            }
            if (registry.byId("layer3").get("checked")) {
               clipLayers.push("Burn");
            }
   if (clipLayers.length === 0) {
               alert("No layers to clip, please select a layer you would like to clip...");
               return;
         }
    
    graphic = new Graphic();
     graphic.geometry = esri.graphicsExtent(map.graphics.graphics);
     var clipFeatureSet = new FeatureSet();
     clipFeature = [];
     dojo.forEach(map.graphics.graphics, function(graphic){
     //if (graphic.geometry.type ="polygon")
              clipFeature.push (graphic);
              });
     clipFeatureSet.features = clipFeature;
    

    
    var params = {
               "Layers_to_Clip": clipLayers,
               "Area_of_Interest": clipFeatureSet,
               "Feature_Format": registry.byId("formatBox").get("value")
  };
  
  
   
            domStyle.set(loading, "display", "inline-block");
            gp.submitJob(params, completeCallback, statusCallback, function (error) {
               alert(error);
               domStyle.set(loading, "display", "none");
            });
   };


Any idea is more than welcome!
Alex

Outcomes