Select to view content in your preferred language

Extract Data Task - Variation on Clip and ship

2197
5
05-04-2011 08:02 AM
BenSayers
Emerging Contributor
Hello,
I am trying to create a variation of the 'Clip and Ship' Extract Data task that instead of having an AOI being passed in the params has a list of the Unique Feature Values.
The idea behind what I am try to do is to implement and kind of cart system where users add lines to the cart (JQuery table) from over a wide geographic area and then when they have collected all of the lines they are interested in, they simply click download and the Extract Data Geoprocessing Task runs on the server and clips and ships a zip file containing a shapefile of the lines they had in the cart.

Can anyone give me any ideas as to how to edit the python script or the Extract Data model to allow this?
Many thanks,
Ben Sayers
0 Kudos
5 Replies
HemingZhu
Frequent Contributor
Hello,
I am trying to create a variation of the 'Clip and Ship' Extract Data task that instead of having an AOI being passed in the params has a list of the Unique Feature Values.
The idea behind what I am try to do is to implement and kind of cart system where users add lines to the cart (JQuery table) from over a wide geographic area and then when they have collected all of the lines they are interested in, they simply click download and the Extract Data Geoprocessing Task runs on the server and clips and ships a zip file containing a shapefile of the lines they had in the cart.

Can anyone give me any ideas as to how to edit the python script or the Extract Data model to allow this?
Many thanks,
Ben Sayers


You can achieve this without modify Extract Data Model. Here is the idea: Once you collected all the lines, create a extent that covers all the lines ( var extent =esri.graphicsExtent(lines);). Use this extent as a geometry to create a graphic. Push this graphic into a featureSet as your AOI parameter -somthing like the following:
    /* parameter AOI - clipFeatureSet*/
    var clipFeature = [];
    clipFeature.push(graphic);
    var clipFeatureSet = new esri.tasks.FeatureSet();
    clipFeatureSet.features = clipFeature;
After that, call your GP task.
Does it make sense?
0 Kudos
BenSayers
Emerging Contributor
Hzhu,
Thank you for you prompt response. I tried something similar to this but I only want the lines that the user has selected and not others around in and around them, is there a way that I can remove the unwanted lines from the selection, without the process being too time consuming? As I have over 8000 lines and the cart only has a capacity of 25 lines.
Hopefully this makes sense and you can help me further.
Many thanks,
Ben
0 Kudos
HemingZhu
Frequent Contributor
Hzhu,
Thank you for you prompt response. I tried something similar to this but I only want the lines that the user has selected and not others around in and around them, is there a way that I can remove the unwanted lines from the selection, without the process being too time consuming? As I have over 8000 lines and the cart only has a capacity of 25 lines.
Hopefully this makes sense and you can help me further.
Many thanks,
Ben


Create a graphic array and push only the selected line into it. And then apply what i said. something like var lines =[]; for (line in your cart...){ lines.push[line];}
0 Kudos
BenSayers
Emerging Contributor
Thanks for your help, I think I'm getting close now.
Here is the code I am using:

function showTResults(results){
 dojo.forEach(results, function(result) {
      var graphic = result.feature;
   var fMarkerSymbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 10, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 0, 0]), 1), new dojo.Color([0, 255, 0, 0.25]));
      var fLineSymbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASH, new dojo.Color([255, 0, 0]), 1);
      var fPolygonSymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_NONE, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASHDOT, new dojo.Color([255, 0, 0]), 2), new dojo.Color([255, 255, 0, 0.25]));
      switch (graphic.geometry.type) {
    case "point":
           graphic.setSymbol(fMarkerSymbol);
     cartstuff.push(graphic);
        break;
        case "polyline":
           graphic.setSymbol(fLineSymbol);
     cartstuff.push(graphic);
  break;
        case "polygon":
            graphic.setSymbol(fPolygonSymbol);
        break;
        }
        map.graphics.add(graphic);
    });
}; 

function doFind(text) {
        params.searchText = text;
        find.execute(params, showTResults);
      }


function download(){
 var clipLayers = [];
 var seismicCount = (jQuery("#selectedSeismicTable").getGridParam("reccount"));
 var wellCount = (jQuery("#selectedSWellTable").getGridParam("reccount"));
 if (seismicCount > 0) {
  clipLayers.push('2D Seismic');
  for (i = 1; i < seismicCount + 1; i++) {
   var ref = $('#selectedSeismicTable').getCell(i, 1);
   doFind(ref);
  }
 };
 if ((jQuery("#selectedRPTable").getGridParam("reccount")) > 0) {
  clipLayers.push('Regional Profiles');
 };
 if ((jQuery("#selectedWellTable").getGridParam("reccount")) > 0) {
  clipLayers.push('Wells');
  for (i = 1; i < wellCount + 1; i++) {
   var ref = $('#selectedWellTable').getCell(i, 1);
   //alert(ref);
   doFind(ref);
  }
 };

var clipFeatureSet = new esri.tasks.FeatureSet();
clipFeatureSet.features = cartstuff;

 var params = {
  "Layers_to_Clip": clipLayers,
  "Area_of_Interest": clipFeatureSet,
  "Feature_Format": "Shapefile - SHP - .shp"
 }
 gp.submitJob(params, completeCallback, statusCallback, function(error){
  alert(error);
 
 });
}
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);
        }
        else if (status === "esriJobSucceeded"){
        }
      }   
function downloadFile(outputFile){
        map.graphics.clear();
        var theurl = outputFile.value.url;  
        window.location = theurl;
      }  

After I click the download button on my cart I get an Error message saying:
Error: esri.config.defaults.io.proxyUrl is not set

I've googled this and looked for help but I'm not sure how to get around this and what causes it.
Any ideas?
0 Kudos
KenDoman
Frequent Contributor
Thanks for your help, I think I'm getting close now.
Here is the code I am using:


After I click the download button on my cart I get an Error message saying:
Error: esri.config.defaults.io.proxyUrl is not set

I've googled this and looked for help but I'm not sure how to get around this and what causes it.
Any ideas?


This usually happens when the server returns something too big for a normal request to handle. Here's the link to set up a proxy page on your server.

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/ags_proxy.htm
0 Kudos