Summarize Elevation Geoprocessing Task Failures

3364
2
09-10-2014 03:50 PM
ToddAtkins
Occasional Contributor

I've been trying to setup a connection from a custom JS API webapp to use the Summarize Elevation GP Task. No matter what I do, the task fails with:

jobStatus: "esriJobFailed"

And the description for the failure is just "Failed.". The idea is that a user clicks a polygon, and in the infowindow is a button that allows them to get the elevation summary. When clicking the elevation button, it passes the selected feature to a function that submits the GP job. Below is a code snippet of what I've been trying:

getSlope: function (feature) {

  var gpElev, params, featureSet, features = [];

  gpElev = new Geoprocessor("http://elevation.arcgis.com/arcgis/rest/services/Tools/Elevation/GPServer/SummarizeElevation");

  featureSet = new FeatureSet();

  features.push(feature);

  featureSet.features = features;

  params = {

  "InputFeatures": featureSet,

  "DEMResolution": "FINEST",

  "IncludeSlopeAspect": true

  }

  function elevSuccess (r) {

  console.log(r);

  }

  function elevStatus (s) {

  console.log(s);

  }

  function elevError (e) {

  console.log(e);

  console.log(params);

  }

  gpElev.submitJob(params, elevSuccess, elevStatus, elevError);

  console.log(gpElev);

  }

I've never really messed around with GP tasks from the web api so maybe I'm just doing something wrong here? Also I should note that I'm using a proxy to grab a token for the GP service, but I get the same results with or without.

All my features are in wkid: 102100 and are retrieved from Server 10.22 with a SQL Server enterprise DB. Web servers tried on both IIS on Server 2012 R2 and Apache2 on Ubuntu Server.

0 Kudos
2 Replies
ToddAtkins
Occasional Contributor

So I figured out what was wrong here. I needed to set the fields parameter of the featureSet. Unfortunately, the fields parameter is not even listed in the API documentation for FeatureSet and the examples I looked at didn't show it either. Fortunately I was able to look through the code for the Elevation Profile template that Esri provides and saw how to setup the FeatureSet and get this to work correctly.

At any rate, the working code is:

getSlope: function (feature) {

  var params, gpElev, featureSet;

  gpElev = new Geoprocessor("https://elevation.arcgis.com/arcgis/rest/services/Tools/Elevation/GPServer/SummarizeElevation");

  featureSet = new FeatureSet();

  featureSet.features = [feature];

  featureSet.fields = [{

  "name": "OBJECTID",

  "type": "esriFieldTypeObjectID",

  "alias": "OBJECTID"

  }];

  params = {

  "InputFeatures": featureSet,

  "DEMResolution": "FINEST",

  "IncludeSlopeAspect": true

  };

  function elevSuccess(r) {

  console.log(r);

  // now run gpElev.getResultData to retrieve the results

  }

  function elevStatus(s) {

  console.log(s);

  }

  function elevError(e) {

  console.log(e);

  }

  gpElev.submitJob(params, elevSuccess, elevStatus, elevError);

  }

0 Kudos
ShilpiJain1
New Contributor

Hi,

I am trying to use this service, but I am stuck at the point where token is generated. I tried it using proxy, but it did not woork. Then, am trying using esri/request. The code is below. Can you help me please?

var layersRequest = esriRequest({

  url: "https://www.arcgis.com/sharing/rest/oauth2/token/",

  content: { f: "json" },

  handleAs: "json",

  callbackParamName: "callback",

  usePost: "true",

  form: {

   'f': 'json',

   'client_id': 'YOUR_APPLICATIONS_CLIENT_ID',

   'client_secret': 'YOUR_APPLICATIONS_CLIENT_SECRET',

   'grant_type': 'client_credentials',

   'expiration': '1440'
  }

});

layersRequest.then(

  function(response) {

   console.log("Success: ", response.layers);

  }, function(error) {

   console.log("Error: ", error.message);

  });

0 Kudos