Select to view content in your preferred language

Stuck on getting getResultImageLayer

4378
27
Jump to solution
10-24-2012 11:22 AM
SmaranHarihar
Deactivated User
I am getting back the success from the GP Tool but for some reason, when I execute the,

gp.getResultImageLayer(jobInfo.jobId,"final_shp", imageParams, function(gpLayer) {    map.addLayer(gpLayer);     });


I am receiving an error on the map.addLayer(gpLayer). The error is,

Network Error: 500 Internal Server Error - <complete path of the job directory where the final.shp is created>. What is causing the layer not to be added to the Map? This is the link.

This is my code,

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html>          <head>         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />         <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />         <!--The viewport meta tag is used to improve the presentation and behavior         of the samples on iOS devices-->         <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"         />         <title>GP Viewshed Task</title>         <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/dojo/dijit/themes/claro/claro.css">         <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/esri/css/esri.css"         />         <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.2compact"></script>         <script type="text/javascript">             dojo.require("esri.map");             dojo.require("esri.tasks.gp");             dojo.require("esri.layers.FeatureLayer");             dojo.require("esri.dijit.Popup");             dojo.require("dijit.TooltipDialog");              var map, gp, featureLayer, dialog;              /*Initialize map, GP*/             function init() {                 var startExtent = new esri.geometry.Extent({                     "xmin": -13644840.338547781,                     "ymin": 4529944.368315823,                     "xmax": -13614265.527233753,                     "ymax": 4552875.476801345,                     "spatialReference": {                         "wkid": 102100                     }                 });                  map = new esri.Map("mapDiv", {                     extent: startExtent                 });                 var streetMap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");                 map.addLayer(streetMap);                 //http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Network/ESRI_DriveTime_US/GPServer/CreateDriveTimePolygons (Drive Time Polygons)                 gp = new esri.tasks.Geoprocessor("http://webgis.arizona.edu/ArcGIS/rest/services/webGIS/Shock_Models/GPServer/Income_Log");                  gp.setOutputSpatialReference({                     wkid: 102100                 });                 dojo.connect(map, "onClick", computeViewShed);                 }              function computeViewShed(evt) {                 map.graphics.clear();                 if (map.graphicsLayerIds.length >= 1) {                     map.removeLayer(map.getLayer(map.graphicsLayerIds[0]));                 }                 var pointSymbol = new esri.symbol.SimpleMarkerSymbol();                 pointSymbol.setSize(20);                 pointSymbol.setOutline(new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0, 0, 0]), 1));                 pointSymbol.setColor(new dojo.Color([0, 0, 255, 0.25]));                  var graphic = new esri.Graphic(evt.mapPoint, pointSymbol);                 map.graphics.add(graphic);                  var features = [];                 features.push(graphic);                 var featureSet = new esri.tasks.FeatureSet();                 featureSet.features = features;                 var params = {                     "Input_Feature_Layer": featureSet,                     "Expression": "50"                 };                 //gp.execute(params, drawViewshed);                 gp.submitJob(params, completeCallback, statusCallback, function (error) {                     alert(error);                     //esri.hide(loading);                 });              }              function completeCallback(jobInfo) {                 if (jobInfo.jobStatus !== "esriJobFailed") {                     //gp.getResultData(jobInfo.jobId,"Output_Polygons", downloadFile);                     var imageParams = new esri.layers.ImageParameters();                     imageParams.imageSpatialReference = map.spatialReference;                     gp.getResultImageLayer(jobInfo.jobId, "final.shp", imageParams, function (gpLayer) {                         map.addLayer(gpLayer);                     });                 }             }               function statusCallback(jobInfo) {                 var status = jobInfo.jobStatus;                 if (status === "esriJobFailed") {                     alert(status);                     //esri.hide(loading);                 } else if (status === "esriJobSucceeded") {                     console.log("Success");                     //esri.hide(loading);                 }             }              dojo.addOnLoad(init);         </script>     </head>          <body class="claro">         <div id="mapDiv" style="width:800px; height:600px; border:1px solid #000;"></div>Click on map to execute my GP Task.</body>  </html>
0 Kudos
27 Replies
SmaranHarihar
Deactivated User
I have in response featureset with a exceededTransferLimit property. This property is true so the number of records exceeds the maximum number configured on you server. (I Have final.shp exceeded transfer limit of 1000 ).

If you have switch on toolbox you comment "gp.getResultImageLayer(j ..." and use only "gp.getResultData(.."


Hi ciava,

I commented out the "gp.getResultImageLayer(j ..." but I am still getting an empty result features array. This is my application.
0 Kudos
SmaranHarihar
Deactivated User
I have in response featureset with a exceededTransferLimit property. This property is true so the number of records exceeds the maximum number configured on you server. (I Have final.shp exceeded transfer limit of 1000 ).

If you have switch on toolbox you comment "gp.getResultImageLayer(j ..." and use only "gp.getResultData(.."


Oh I think I got why I am not able to get back the results. I ran this command,

>>> results.value.exceededTransferLimit

true


The number of features that are being returned are 3076 and I think that is where it is failing. Any idea how I can restricted it to min features? There is field called value and I need to display the value of only these features. How is it that I am able to transfer same number of features in FLEX but not in JavaScript?
0 Kudos
nicogis
MVP Alum
this value is managed server side from 'Maximum Number of records returned by Server'

0 Kudos
SmaranHarihar
Deactivated User
this value is managed server side from 'Maximum Number of records returned by Server'



Thanks ciava, now I am able to get back all the results but is there no way to get back the results with the result image layer?

In the result image layer I am simply getting back the layer with the coloration. The purpose of getting back the layer is to display the values which is incomplete.

Any idea if it is possible?
0 Kudos
nicogis
MVP Alum
Is a problem render the featureset in client side?
0 Kudos
SmaranHarihar
Deactivated User
Is a problem render the featureset in client side?


Well I have the results now but how can I create the polygons. Would assigning it to a featureCollection work?

Can I assign,

 var featureCollection = {
      "layerDefinition": null,
      "featureSet": {
        "features": results.value.features,
        "geometryType": "esriGeometryPolygon"
      }
    };


Also to create render I need,

       
//create renderer
        var renderer = new esri.renderer.UniqueValueRenderer(defaultSymbol, "SUB_REGION");

        //add symbol for each possible value
        renderer.addValue("Pacific", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255, 0, 0, 0.5])));


But this is rendering for specific values. How can I assign rendering for a range of values?
0 Kudos
SmaranHarihar
Deactivated User
Is a problem render the featureset in client side?


Hi ciava,

I created the following featureLayer and I am able to add it to the map as well but for some reason I am not able to see it.

This is the entire code,

function addResults(results) {
  //console.log(results);
  var features = results.value.features;
  
  var layerDefinition = {
   "geometryType": "esriGeometryPolygon",
   "fields": [{
    "name": "FID",
    "alias": "ID",
    "type": "esriFieldTypeOID"
   }, {
    "name": "STATE_NAME",
    "alias": "State Name: ",
    "type": "esriFieldTypeString"
   }, {
    "name": "NAME",
    "alias": "County Name: ",
    "type": "esriFieldTypeString"
   }, {
    "name": "value",
    "type": "esriFieldTypeDouble",
    "alias": "Absolute Value"
   }, {
    "name": "RESULT2",
    "type": "esriFieldTypeDouble",
    "alias": "Percentage Change"
   }]
}
  var featureCollection = {
          "layerDefinition": layerDefinition,
          "featureSet": {
            "features": features
          }
        };
  var states_Symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, //EVENTS
     new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,  //EVENTS
     new dojo.Color([255,255,255,0.35]), 1),  //EVENTS
     new dojo.Color([125,125,125,0.35]));
  
  var popupTemplate = new esri.dijit.PopupTemplate({
    title: "{NAME}",
    fieldInfos: [{
     fieldName: "STATE_NAME",
     visible: true,
     label: "State Name: "
    },
    {
     fieldName: "value",
     visible: true,
     label: "Absolute Change: $"
    },
    {
     fieldName: "RESULT2",
     visible: true,
     label: "Percentage Change: "
    }
    ]
   });
  
  resultLyr = new esri.layers.FeatureLayer(featureCollection, {
          id: 'resultLayer',
          infoTemplate: popupTemplate
        });
  resultLyr.setRenderer(new esri.renderer.SimpleRenderer(states_Symbol));
  map.addLayers([resultLyr]);
  
  dojo.connect(resultLyr,"onClick",function(evt){
           map.infoWindow.setFeatures([evt.graphic]);
        });

 
 }
0 Kudos
SmaranHarihar
Deactivated User
Is a problem render the featureset in client side?


It seems that get result data only fetches the data not the geometry and so I have the data but not the layer. Any idea how I can    combine and get the layer and the data together?
0 Kudos