Extract Data Task GP Not Extracting Features - PLEASE HELP!!!

4797
20
12-26-2011 08:58 AM
IanWint
New Contributor
I created a geoprocessing (GP) task to extract features from a SDE geodatabase.  I created the GP task and added it to my MXD using the instructions from this video:  http://www.youtube.com/watch?v=HsMK9ZtYN5k.

I then re-created the "clip and ship" javascript api sample using the instructions posted here:  http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm.  I used my mxd and ArcGIS Server services when I created my version of the sample posted here:  http://gis.fortlauderdale.gov/DataDownloads/esriSample.html.

The GP works as expected when initiated from ArcMap by right clicking on the "Extract Data Task," selecting "Open," then interactively drawing a graphic for clipping the features.  However, the GP does not clip the features when initiated from my sample website (http://gis.fortlauderdale.gov/DataDownloads/esriSample.html).  It initiates the GP but the resulting files that are downloaded only contain the structure of the files.  They do not include any features.  It is almost as if the application is ignoring my interactive graphic.  This is getting frustrating as I've spent several days trying to figure out the problem.  I am hoping someone will please chime in to provide some assistance.

Thanks in advance.
0 Kudos
20 Replies
HemingZhu
Occasional Contributor III
I created a geoprocessing (GP) task to extract features from a SDE geodatabase.  I created the GP task and added it to my MXD using the instructions from this video:  http://www.youtube.com/watch?v=HsMK9ZtYN5k.

I then re-created the "clip and ship" javascript api sample using the instructions posted here:  http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm.  I used my mxd and ArcGIS Server services when I created my version of the sample posted here:  http://gis.fortlauderdale.gov/DataDownloads/esriSample.html.

The GP works as expected when initiated from ArcMap by right clicking on the "Extract Data Task," selecting "Open," then interactively drawing a graphic for clipping the features.  However, the GP does not clip the features when initiated from my sample website (http://gis.fortlauderdale.gov/DataDownloads/esriSample.html).  It initiates the GP but the resulting files that are downloaded only contain the structure of the files.  They do not include any features.  It is almost as if the application is ignoring my interactive graphic.  This is getting frustrating as I've spent several days trying to figure out the problem.  I am hoping someone will please chime in to provide some assistance.

Thanks in advance.


The issue might has something to do with the SR. The SR of your mxd/msd might be different from your AOI (102100). you could either project the AOI to SR of your layers or set up SR of you mxd/msd to 102100.
0 Kudos
IanWint
New Contributor
Thanks Heming.  I appreciate the input.  I'm fairly new to creating ArcGIS Server web apps.

I created a new mxd and made the spatial reference of the Data Frame to 102100.  I then brought in all the feature classes into that data frame.  I then tested the Extract Data Task in the MXD and it worked flawlessly.  However, it's a different story through the web app.  The app is now returning an "Error Submitting Job" message, obviously from the JavaScript in the sample. I checked the spatial reference of the ArcGIS Server Map service and it does confirm as 102100. I guess I have some more troubleshooting ahead of me.

One question I have:  I'm having a hard time figuring out what you meant by "AOI."
0 Kudos
HemingZhu
Occasional Contributor III
Thanks Heming.  I appreciate the input.  I'm fairly new to creating ArcGIS Server web apps.

I created a new mxd and made the spatial reference of the Data Frame to 102100.  I then brought in all the feature classes into that data frame.  I then tested the Extract Data Task in the MXD and it worked flawlessly.  However, it's a different story through the web app.  The app is now returning an "Error Submitting Job" message, obviously from the JavaScript in the sample. I checked the spatial reference of the ArcGIS Server Map service and it does confirm as 102100. I guess I have some more troubleshooting ahead of me.

One question I have:  I'm having a hard time figuring out what you meant by "AOI."


AOI -Area of Interests that references the polygon graphic you draw to clip the features.
0 Kudos
IanWint
New Contributor
AOI -Area of Interests that references the polygon graphic you draw to clip the features.


Lol, that acronym had me stumped. I was fearing it was something more technical that I hadn't yet encountered.  Thanks for clarifying.
0 Kudos
IanWint
New Contributor
The problem I am having is definitely an issue of spatial reference (SR).  I'm thinking the specific problem is the transformation used to go from our default SR to the ArcGIS Online SR.  All our datasets use the NAD_1983_Stateplane_Florida_East_FIPS_0901_Feet XY Coordinate System.  I'm able to get my web app to correctly clip and download the data when I set my MXD Data Frame document to use just this coordinate system without a basemap.  However, the clip and extract does not work if I set up my Data Frame in any of the web mercator systems.  This allows me to see our data overlaid on the basemap but it doesn't clip, presumably because the transformation from State Plane to web mercator is incorrect.  Neither does the clip work if I set up the Data Frame to our regular State Plane NAD 1983 Florida East (0901) and call the World_Street_Map ArcGIS online basemap through the web app.  If someone could point me in the right direction of how to correct this I would be most appreciative.  Here are the details of our XY  NAD_1983_StatePlane_Florida_East_FIPS_0901_Feet Coordinate System:

Projection: Transverse_Mercator
False_Easting: 656166.666667
False_Northing: 0.000000
Central_Meridian: -81.000000
Scale_Factor: 0.999941
Latitude_Of_Origin: 24.333333
Linear Unit: Foot_US (0.304801)

Geographic Coordinate System: GCS_North_American_1983
Angular Unit: Degree (0.017453292519943295)
Prime Meridian: Greenwich (0.000000000000000000)
Datum: D_North_American_1983
  Spheroid: GRS_1980
    Semimajor Axis: 6378137.000000000000000000
    Semiminor Axis: 6356752.314140356100000000
    Inverse Flattening: 298.257222101000020000
0 Kudos
HemingZhu
Occasional Contributor III
The problem I am having is definitely an issue of spatial reference (SR).  I'm thinking the specific problem is the transformation used to go from our default SR to the ArcGIS Online SR.  All our datasets use the NAD_1983_Stateplane_Florida_East_FIPS_0901_Feet XY Coordinate System.  I'm able to get my web app to correctly clip and download the data when I set my MXD Data Frame document to use just this coordinate system without a basemap.  However, the clip and extract does not work if I set up my Data Frame in any of the web mercator systems.  This allows me to see our data overlaid on the basemap but it doesn't clip, presumably because the transformation from State Plane to web mercator is incorrect.  Neither does the clip work if I set up the Data Frame to our regular State Plane NAD 1983 Florida East (0901) and call the World_Street_Map ArcGIS online basemap through the web app.  If someone could point me in the right direction of how to correct this I would be most appreciative.  Here are the details of our XY  NAD_1983_StatePlane_Florida_East_FIPS_0901_Feet Coordinate System:

Projection: Transverse_Mercator
False_Easting: 656166.666667
False_Northing: 0.000000
Central_Meridian: -81.000000
Scale_Factor: 0.999941
Latitude_Of_Origin: 24.333333
Linear Unit: Foot_US (0.304801)

Geographic Coordinate System: GCS_North_American_1983
Angular Unit: Degree (0.017453292519943295)
Prime Meridian: Greenwich (0.000000000000000000)
Datum: D_North_American_1983
  Spheroid: GRS_1980
    Semimajor Axis: 6378137.000000000000000000
    Semiminor Axis: 6356752.314140356100000000
    Inverse Flattening: 298.257222101000020000


Have you tried to project AOI to your native SR -wkid 102658 before clipping and extraction. Making mxd/msd data from to wkid 102100 or Projecting your AOI to wkid 102658 should do the trick (i have done exactly the samp project and both work for me). if you don't midn posting your code here, i will look at it...
0 Kudos
IanWint
New Contributor
Thanks Heming.  I think conceptual your idea of projecting the AOI is the way to go.  However, I don't know how to go about that from a technical standpoint.  It would be easy if my AOI was an already established layer.  In this case it is an interactive graphic that only exists once the user draws it.  I don't know how to project those as I'm new to developing ArcGIS Server apps. I am including the code for the esri sample I modified to use our data and the online basemap.  Note that the MapServer referenced in the code is now in my state plane SR, but that should be irrelevant.  I can always re-create it to the SR I need to make the app function with the basemap (wkid:102100 I believe is also wkid: 4326).  Thanks again for your generousity.

<script type="text/javascript">
      dojo.require("dijit.dijit"); // optimize: load dijit layer
      dojo.require("dijit.layout.BorderContainer");
      dojo.require("dojox.layout.FloatingPane");
      dojo.require("dijit.layout.ContentPane");
      dojo.require("dijit.form.CheckBox");
      dojo.require("dijit.form.ComboBox");
      dojo.require("esri.map");

      var gp, map;
      var loading;
      var selectionToolbar;

      function init() {
        esri.config.defaults.io.proxyUrl = "/arcgisserver/apis/javascript/proxy/proxy.ashx";
        loading = dojo.byId("loadingImg");
        var initialExtent = new esri.geometry.Extent({ "xmin": -8931915.50, "ymin": 3011446.77, "xmax": -8914717.17, "ymax": 3022912.32, "spatialReference": { "wkid": 102100} });
        map = new esri.Map("map", {
          extent: initialExtent
        });
        map = new esri.Map("map");
        dojo.connect(map, 'onLoad', function(map) {
          initSelectionToolbar();
          //resize the map when the browser resizes
          dojo.connect(dijit.byId('map'), 'resize', map,map.resize);
        });
         
        //var basemapUrl = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";
        //var basemap = new esri.layers.ArcGISTiledMapServiceLayer(basemapUrl);
        //map.addLayer(basemap);
        var homelandSecurity = new esri.layers.ArcGISDynamicMapServiceLayer("http://gis.fortlauderdale.gov/ArcGIS/rest/services/AppsITS/DataExtractionDownloads/MapServer");
        map.addLayer(homelandSecurity);
        
        gp = new esri.tasks.Geoprocessor("http://gis.fortlauderdale.gov/ArcGIS/rest/services/AppsITS/DataExtractionDownloads/GPServer/Extract%20Data%20Task");
        gp.setOutSpatialReference({wkid:102100});
        
        var basemapUrl = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";
        var basemap = new esri.layers.ArcGISTiledMapServiceLayer(basemapUrl);
        map.addLayer(basemap);
      }
      
      function initSelectionToolbar(myMap){
        selectionToolbar = new esri.toolbars.Draw(map);
        dojo.connect(selectionToolbar, "onDrawEnd", function(geometry) {
          selectionToolbar.deactivate();
          var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASHDOT, new dojo.Color([255,0,0]), 2), new dojo.Color([255,255,0,0.25]));
          var graphic = new esri.Graphic(geometry, symbol);
          map.graphics.add(graphic);

        });
      }
      function activateTool(type){
        selectionToolbar.activate();
      }
      
      function extractData(){
        //get clip layers
        var clipLayers = [];
        if (dijit.byId('layer0').checked) { clipLayers.push('Bridges (Moveable)'); }
        if (dijit.byId('layer1').checked) { clipLayers.push('Building Permits'); }
        if (dijit.byId('layer2').checked) { clipLayers.push('Businesses'); }
        if (dijit.byId('layer3').checked) { clipLayers.push('Fire Stations'); }
        if (dijit.byId('layer4').checked) { clipLayers.push('Lifeguard Towers'); }
        if (dijit.byId('layer5').checked) { clipLayers.push('Ocean Buoys'); }
        if (dijit.byId('layer6').checked) { clipLayers.push('Section Points (Florida PLSS)'); }
        if (dijit.byId('layer7').checked) { clipLayers.push('Survey Benchmarks'); }
        if (dijit.byId('layer8').checked) { clipLayers.push('City Limits (Fort Lauderdale)'); }
        if(clipLayers.length === 0 || map.graphics.graphics.length === 0){
          alert('Select layers to extract and area of interest');
          return;
        }
        var features =[];
        features.push(map.graphics.graphics[0]);
        var featureSet = new esri.tasks.FeatureSet();
        featureSet.features = features;

        var params = {"Layers_to_Clip":clipLayers,
          "Area_of_Interest": featureSet,
          "Feature_Format": dijit.byId('formatBox').value
        }
        esri.show(loading);
        gp.submitJob(params, completeCallback , statusCallback,function(error){
          alert(error);
          esri.hide(loading);
        });
      }
      function completeCallback(jobInfo){
        if(jobInfo.jobStatus !== "esriJobFailed"){
          gp.getResultData(jobInfo.jobId,"Output_Zip_File", downloadFile);
        }
      }
      function statusCallback(jobInfo) {
        var status = jobInfo.jobStatus;
        if(status === "esriJobFailed"){
          alert(status);
          esri.hide(loading);
        }
        else if (status === "esriJobSucceeded"){
          esri.hide(loading);
        }
      }
      function downloadFile(outputFile){
        map.graphics.clear();
        var theurl = outputFile.value.url;  
        window.location = theurl;
      }

      //show map on load 
      dojo.addOnLoad(init);
    </script>
0 Kudos
HemingZhu
Occasional Contributor III
Thanks Heming. I think conceptual your idea of projecting the AOI is the way to go. However, I don't know how to go about that from a technical standpoint. It would be easy if my AOI was an already established layer. In this case it is an interactive graphic that only exists once the user draws it. I don't know how to project those as I'm new to developing ArcGIS Server apps. I am including the code for the esri sample I modified to use our data and the online basemap. Note that the MapServer referenced in the code is now in my state plane SR, but that should be irrelevant. I can always re-create it to the SR I need to make the app function with the basemap (wkid:102100 I believe is also wkid: 4326). Thanks again for your generousity. 

<script type="text/javascript">
      dojo.require("dijit.dijit"); // optimize: load dijit layer
      dojo.require("dijit.layout.BorderContainer");
      dojo.require("dojox.layout.FloatingPane");
      dojo.require("dijit.layout.ContentPane");
      dojo.require("dijit.form.CheckBox");
      dojo.require("dijit.form.ComboBox");
      dojo.require("esri.map");

      var gp, map;
      var loading;
      var selectionToolbar;
      var gsvc;
      function init() {
        esri.config.defaults.io.proxyUrl = "/arcgisserver/apis/javascript/proxy/proxy.ashx"; //need your own proxy        loading = dojo.byId("loadingImg");
        var initialExtent = new esri.geometry.Extent({ "xmin": -8931915.50, "ymin": 3011446.77, "xmax": -8914717.17, "ymax": 3022912.32, "spatialReference": { "wkid": 102100} });
        map = new esri.Map("map", {
          extent: initialExtent
        });
        map = new esri.Map("map");
        dojo.connect(map, 'onLoad', function(map) {
          initSelectionToolbar();
          //resize the map when the browser resizes
          dojo.connect(dijit.byId('map'), 'resize', map,map.resize);
        });
         
        //var basemapUrl = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";
        //var basemap = new esri.layers.ArcGISTiledMapServiceLayer(basemapUrl);
        //map.addLayer(basemap);
        var homelandSecurity = new esri.layers.ArcGISDynamicMapServiceLayer("http://gis.fortlauderdale.gov/ArcGIS/rest/services/AppsITS/DataExtractionDownloads/MapServer");
        map.addLayer(homelandSecurity);
        gsvc = new esri.tasks.GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");        gp = new esri.tasks.Geoprocessor("http://gis.fortlauderdale.gov/ArcGIS/rest/services/AppsITS/DataExtractionDownloads/GPServer/Extract%20Data%20Task");
       // don't need if you results are in state plate SR  gp.setOutSpatialReference({wkid:102100});        
        var basemapUrl = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";
        var basemap = new esri.layers.ArcGISTiledMapServiceLayer(basemapUrl);
        map.addLayer(basemap);
      }
      
      function initSelectionToolbar(myMap){
        selectionToolbar = new esri.toolbars.Draw(map);
        dojo.connect(selectionToolbar, "onDrawEnd", function(geometry) {
          selectionToolbar.deactivate();
          var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASHDOT, new dojo.Color([255,0,0]), 2), new dojo.Color([255,255,0,0.25]));
          var graphic = new esri.Graphic(geometry, symbol);
          map.graphics.add(graphic);

        });
      }
      function activateTool(type){
        selectionToolbar.activate();
      }
      
      function extractData(){
        var outSR = new esri.SpatialReference({ wkid: 2236});
        gsvc.project([ map.graphics.graphics[0] ], outSR, function(graphics) {
             var graphic =graphics[0];            //get clip layers
            var clipLayers = [];
            if (dijit.byId('layer0').checked) { clipLayers.push('Bridges (Moveable)'); }
            if (dijit.byId('layer1').checked) { clipLayers.push('Building Permits'); }
            if (dijit.byId('layer2').checked) { clipLayers.push('Businesses'); }
            if (dijit.byId('layer3').checked) { clipLayers.push('Fire Stations'); }
            if (dijit.byId('layer4').checked) { clipLayers.push('Lifeguard Towers'); }
            if (dijit.byId('layer5').checked) { clipLayers.push('Ocean Buoys'); }
            if (dijit.byId('layer6').checked) { clipLayers.push('Section Points (Florida PLSS)'); }
            if (dijit.byId('layer7').checked) { clipLayers.push('Survey Benchmarks'); }
            if (dijit.byId('layer8').checked) { clipLayers.push('City Limits (Fort Lauderdale)'); }
            if(clipLayers.length === 0 || graphics.length === 0){
                alert('Select layers to extract and area of interest');
                return;
            }
            var features =[];
            features.push(graphic);
            var featureSet = new esri.tasks.FeatureSet();
            featureSet.features = features;

            var params = {"Layers_to_Clip":clipLayers,
                                "Area_of_Interest": featureSet,
                                "Feature_Format": dijit.byId('formatBox').value
            }
            esri.show(loading);
            gp.submitJob(params, completeCallback , statusCallback,function(error){
                 alert(error);
                 esri.hide(loading);
            });
         }); 
}
      function completeCallback(jobInfo){
        if(jobInfo.jobStatus !== "esriJobFailed"){
          gp.getResultData(jobInfo.jobId,"Output_Zip_File", downloadFile);
        }
      }
      function statusCallback(jobInfo) {
        var status = jobInfo.jobStatus;
        if(status === "esriJobFailed"){
          alert(status);
          esri.hide(loading);
        }
        else if (status === "esriJobSucceeded"){
          esri.hide(loading);
        }
      }
      function downloadFile(outputFile){
        map.graphics.clear();
        var theurl = outputFile.value.url;  
        window.location = theurl;
      }

      //show map on load 
      dojo.addOnLoad(init);
    </script>


I modified part of code to include the logice to transfer your aoi to state plate. you might need to reorginalize or debug you code. Hope it will give you a hint. You might also need to use your own proxy.
0 Kudos
IanWint
New Contributor
Thanks Heming. I applied your code to my js file. I think everything is good above the start of function extractData(). Nothing happens when I use Chrome to click the "Extract" button. At least IE gave the following error:

Message: 'spatialReference.wkid' is null or not an object
Line: 48
Char: 427431
Code: 0
URI: http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.6

Boy, this is going to ruin my new year's eve weekend 😞

Question: for the line that reads "var outSR = new esri.SpatialReference ( { wkid : 2236});" does wkid need to be quoted so it is written ad "wkid"?

Thanks again for your help. I'll do some research over the weekend while following the path you set out. At the same time, if something jumps out at you I would appreciate feedback. Here is my code at the moment:

dojo.require("dijit.dijit");
// optimize: load dijit layer
dojo.require("dijit.layout.BorderContainer");
dojo.require("dojox.layout.FloatingPane");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.form.CheckBox");
dojo.require("dijit.form.ComboBox");
dojo.require("esri.map");
dojo.require("esri.dijit.Popup");
dojo.require("esri.geometry");

/*------------------------------------*/
// GLOBAL VARIABLES
/*-----------------------------------*/
var gp, map;
var loading;
var selectionToolbar;
//hzhu added
var gsvc;

function init() {
 //configure map zoom animation to be slower (Gives a cool effect, almost similar to the Flex Viewer zoom)
 //The default for zoomDuration in milliseconds is 250
 //Default for zoomRate is 25
 esri.config.defaults.map.zoomDuration = 1000;
 esri.config.defaults.map.zoomRate = 50;

 //configure map pan animation to be slower
 //time in milliseconds; default panDuration:250
 //refresh rate of zoom animation; default panRate:25
 esri.config.defaults.map.panDuration = 1000;
 esri.config.defaults.map.panRate = 50;
 
 //esri.config.defaults.io.proxyUrl = "/arcgisserver/apis/javascript/proxy/proxy.ashx";
 esri.config.defaults.io.proxyUrl = "/arcgisserver/apis/javascript/proxy/proxy.ashx";
 loading = dojo.byId("loadingImg");
 var initialExtent = new esri.geometry.Extent({"xmin":-8931399.85128929,"ymin":3006918.03708705,"xmax":-8913140.86444157,"ymax":3026297.04737907,"spatialReference":{"wkid":102100}});
 map = new esri.Map("map", {
  extent: initialExtent
 });
 dojo.connect(map, 'onLoad', function(map) {
  initSelectionToolbar();
  //resize the map when the browser resizes
  dojo.connect(dijit.byId('map'), 'resize', map, map.resize);
 });
  
 var basemapUrl = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";
 var basemap = new esri.layers.ArcGISTiledMapServiceLayer(basemapUrl);
 map.addLayer(basemap);
 //var FortLaudMapLayers = new esri.layers.ArcGISDynamicMapServiceLayer("http://gis.fortlauderdale.gov/ArcGIS/rest/services/AppsITS/DataExtractionDownloads/MapServer");
 var FortLaudMapLayers = new esri.layers.ArcGISDynamicMapServiceLayer("http://gis.fortlauderdale.gov/ArcGIS/rest/services/AppsITS/DataExtraction/MapServer");
 map.addLayer(FortLaudMapLayers);
 //hzhu added
 gsvc = new esri.tasks.GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
 //gp = new esri.tasks.Geoprocessor("http://gis.fortlauderdale.gov/ArcGIS/rest/services/AppsITS/DataExtractionDownloads/GPServer/Extract%20Data%20Task");
 gp = new esri.tasks.Geoprocessor("http://gis.fortlauderdale.gov/ArcGIS/rest/services/AppsITS/DataExtraction/GPServer/Extract%20Data%20Task");

}

function initSelectionToolbar(myMap) {
 selectionToolbar = new esri.toolbars.Draw(map);
 dojo.connect(selectionToolbar, "onDrawEnd", function(geometry) {
  selectionToolbar.deactivate();
  var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASHDOT, new dojo.Color([255, 0, 0]), 2), new dojo.Color([255, 255, 0, 0.25]));
  var graphic = new esri.Graphic(geometry, symbol);
  map.graphics.add(graphic);
 });
}

function activateTool(type) {
 selectionToolbar.activate();
}

function extractData() {
 //hzhu added
 var outSR = new esri.SpatialReference({
  wkid : 2236
 });
 //hzhu added
 gsvc.project([map.graphics.graphics[0]], outSR, function(graphics) {
  //hzhu added
  var graphic = graphics[0];
  //get clip layers
  var clipLayers = [];
  if(dijit.byId('layer0').checked) {
   clipLayers.push('Bridges (Moveable)');
  }
  if(dijit.byId('layer1').checked) {
   clipLayers.push('Building Permits');
  }
  if(dijit.byId('layer2').checked) {
   clipLayers.push('Businesses');
  }
  if(dijit.byId('layer3').checked) {
   clipLayers.push('Fire Stations');
  }
  if(dijit.byId('layer4').checked) {
   clipLayers.push('Lifeguard Towers');
  }
  if(dijit.byId('layer5').checked) {
   clipLayers.push('Ocean Buoys');
  }
  if(dijit.byId('layer6').checked) {
   clipLayers.push('Section Points (Florida PLSS)');
  }
  if(dijit.byId('layer7').checked) {
   clipLayers.push('Survey Benchmarks');
  }
  if(dijit.byId('layer8').checked) {
   clipLayers.push('City Limits (Fort Lauderdale)');
  }
  //hzhu modified
  if(clipLayers.length === 0 || graphics.length === 0) {
   alert('Select layers to extract and area of interest');
   return;
  }
  var features = [];
  features.push(graphic);
  var featureSet = new esri.tasks.FeatureSet();
  featureSet.features = features;

  var params = {
   "Layers_to_Clip" : clipLayers,
   "Area_of_Interest" : featureSet,
   "Feature_Format" : dijit.byId('formatBox').value
  }
  esri.show(loading);
  gp.submitJob(params, completeCallback, statusCallback, function(error) {
   alert(error);
   esri.hide(loading);
  });
 });
}

function completeCallback(jobInfo) {
 if(jobInfo.jobStatus !== "esriJobFailed") {
  gp.getResultData(jobInfo.jobId, "Output_Zip_File", downloadFile);
 }
}

function statusCallback(jobInfo) {
 var status = jobInfo.jobStatus;
 if(status === "esriJobFailed") {
  alert(status);
  esri.hide(loading);
 } else if(status === "esriJobSucceeded") {
  esri.hide(loading);
 }
}

function downloadFile(outputFile) {
 map.graphics.clear();
 var theurl = outputFile.value.url;
 window.location = theurl;
}

//show map on load
dojo.addOnLoad(init);
0 Kudos