Query results feature set to a brand new Features set

961
2
05-02-2014 01:24 PM
AlexGole1
New Contributor II
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
0 Kudos
2 Replies
JulianInskip
Occasional Contributor
Hi Alex. I am not sure if I understand you correctly. Are you trying be able to select a county name from a dropdown list for the Feature Set. If so, I did something like this for our area, but I changed the GP Tool itself (see graphic).

Instead of using a Feature Set, I use a Make Feature Layer that has an inline variable for the Expression. I then make the variable string a parameter and enter the options for the expression as a value list filter.

This works well in my flex application but I have not tried this in javascript.
0 Kudos
AlexGole1
New Contributor II
Hi Alex. I am not sure if I understand you correctly. Are you trying be able to select a county name from a dropdown list for the Feature Set. If so, I did something like this for our area, but I changed the GP Tool itself (see graphic).

Instead of using a Feature Set, I use a Make Feature Layer that has an inline variable for the Expression. I then make the variable string a parameter and enter the options for the expression as a value list filter.

This works well in my flex application but I have not tried this in javascript.


Hi Julian,
Thanks for your reply! My goal was to be able to extract data by drawing the extent (same as the example), extract by queried county layer, and by unit layer, so three extraction methods. I finally made it work a few weeks ago. I just had to use the feature set as it is in the original Extract data tool though not the make feature layer tool. I made three separate functions for each extraction method and created three UI buttons to trigger these functions. Now I am trying to trigger either one of these functions independently using just only one button push by using a JS listener...Not an easy task for a newbie like me :-).

Alex
0 Kudos