Select to view content in your preferred language

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

5954
20
12-26-2011 08:58 AM
IanWint
Deactivated User
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
Reynaldde_Castro
Deactivated User
I still get an object error. 


here is my code.  Maybe you can see something I am missing.


<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 = "proxy.ashx";
            loading = dojo.byId("loadingImg");
            var initialExtent = new esri.geometry.Extent({ "xmin": 2118554.27258295, "ymin": 1077280.74820994, "xmax": 2397176.40706298, "ymax": 1243287.9891281, "spatialReference": { "wkid": 3436} });
            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 homelandSecurity = new esri.layers.ArcGISDynamicMapServiceLayer("http://dot084dgis01/ArcGIS/rest/services/ClipAndShip/ClipAndShip1Map/MapServer/");
            map.addLayer(homelandSecurity);

            gp = new esri.tasks.Geoprocessor("http://dot084dgis01/ArcGIS/rest/services/DataSharing/GpClipAndShip/GPServer/Extract%20Data%20Task");
            gp.setOutSpatialReference({ wkid: 3436 });


           
        }

        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('layer1').checked) { clipLayers.push('HWY2010'); }
            if (dijit.byId('layer2').checked) { clipLayers.push('RRX2010'); }
            if (dijit.byId('layer3').checked) { clipLayers.push('STR2010'); }
            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;

            esri.setRequestPreCallback(function (ioargs) {
                if (ioargs.content.Area_of_Interest) {
                    var aoijson = dojo.fromJson(ioargs.content.Area_of_Interest);

                    aoijson.spatialReference = aoijson.sr;
                    ioargs.content.Area_of_Interest = dojo.toJson(aoijson);
                    console.log('test');

                }
                return ioargs;
            });
                    }
       
        //show map on load
        function showLoading() {
            esri.show(loading);
            map.disableMapNavigation();
            map.hideZoomSlider();
        }

        function hideLoading(error) {
            esri.hide(loading);
            map.enableMapNavigation();
            map.showZoomSlider();

        }


        dojo.addOnLoad(init);
    </script>
  </head>
  <body class="claro">
    <div dojotype="dijit.layout.BorderContainer" design="headline" gutters="false" style="width: 100%; height: 100%;margin:0;">
      <div id="map" dojotype="dijit.layout.ContentPane" region="center">
        <div dojoType="dojox.layout.Dock" id="dock"></div>
       
        <div dojoType="dojox.layout.FloatingPane"  title="Extract Data" dockTo="dock" id="floater" style="visibility:hidden;" closable="false" resizable="true"  dockable="true" >
        1.Select area of interest<br />
          <button dojoType="dijit.form.Button" iconClass="polyIcon" showLabel="false" onClick="map.graphics.clear();selectionToolbar.activate(esri.toolbars.Draw.POLYGON);">Polygon</button>
          <button dojoType="dijit.form.Button" iconClass="freehandIcon" showLabel="false" onClick="map.graphics.clear();selectionToolbar.activate(esri.toolbars.Draw.FREEHAND_POLYGON);">Freehand</button><br />
        2.Select Layers to extract data from<br />
            <input id="layer1" dojoType="dijit.form.CheckBox" checked="checked" type="checkbox"/>
            <label for="layer1">STR2010</label><br />
            <input id="layer2" dojoType="dijit.form.CheckBox" checked="checked" type="checkbox"/>
            <label for="layer2">RRX2010</label><br />
            <input id="layer3" dojoType="dijit.form.CheckBox" checked="checked" type="checkbox"/>
            <label for="layer3">HWY2010</label><br />
        3.Specify download format<br />
            <select dojoType="dijit.form.ComboBox" id="formatBox">
              <option>Shapefile - SHP - .shp</option>
              <option>File Geodatabase - GDB - .gdb</option>
              <option>Autodesk AutoCAD - DXF_R2007 - .dxf</option>
              <option>Autodesk AutoCAD - DWG_R2007 - .dwg</option>
              <option>Bentley Microstation Design (V8) - DGN_V8 - .dgn</option>           
            </select>
       <button dojoType="dijit.form.Button"  onClick="extractData();">Extract Data</button>
       <img id="loadingImg" src="loading.gif" style="position:absolute; left:100px; bottom:8px; z-index:100;display:none;" />
      </div> 
      </div>
  
     </div>
  </body>

</html>
0 Kudos