OK,
So i used the geoprocessing/viewshed example to come up with the code below. It makes the call and receives a reply. However, the geometry that gets returned is only a polyline, and not a polylineZ (containing z values of the ground). Does anyone have an idea why it does not appear to be working? I thought it was something in the fieldlist but i tried multiple things there (including none), but nothing seemed to change the returned result.
var myProfileTask = await GeoprocessingTask.CreateAsync(new Uri(_viewshedUrl));
List<Field> fieldList = new List<Field>();
fieldList.Add(new Field(FieldType.OID, "ObjectID", "ObjectID", 10));
fieldList.Add(new Field(FieldType.Float64, "Shape_Length", "Shape_Length", 10));
var myInputFeatures = new FeatureCollectionTable(new List<Field>(), GeometryType.Polyline, SpatialReferences.WebMercator);
Feature myInputFeature = myInputFeatures.CreateFeature();
_selectedGraphics[0].Attributes.Add("ObjectID", 1);
_selectedGraphics[0].Attributes.Add("Shape_Length", GeometryEngine.LengthGeodetic(_selectedGraphics[0].Geometry,LinearUnits.Meters,GeodeticCurveType.Geodesic));
myInputFeature.Geometry = _selectedGraphics[0].Geometry;
await myInputFeatures.AddFeatureAsync(myInputFeature);
GeoprocessingParameters myProfileParameters =
new GeoprocessingParameters(GeoprocessingExecutionType.SynchronousExecute);
myProfileParameters.OutputSpatialReference = SpatialReferences.WebMercator; ;
myProfileParameters.Inputs.Add("InputLineFeatures", new GeoprocessingFeatures(myInputFeatures));
var myViewshedJob = myProfileTask.CreateJob(myProfileParameters);
try
{
GeoprocessingResult myAnalysisResult = await myViewshedJob.GetResultAsync();
GeoprocessingFeatures myProfileResultFeatures = myAnalysisResult.Outputs["OutputProfile"] as GeoprocessingFeatures;
// Add all the results as a graphics to the map
IFeatureSet myViewshedAreas = myProfileResultFeatures.Features;
foreach (var myFeature in myViewshedAreas)
{
_resultOverlay.Graphics.Add(new Graphic(myFeature.Geometry));
}
}
catch (Exception ex)
{
// Display an error message if there is a problem
//if (myViewshedJob.Status == JobStatus.Failed && myViewshedJob.Error != null)
// _userViewModel.UserMessage="Executing geoprocessing failed. " + myViewshedJob.Error.Message, "Geoprocessing error";
//else
// MessageBox.Show("An error occurred. " + ex.ToString(), "Sample error");
}
finally
{
// Indicate that the geoprocessing is not running
//SetBusy(false);
}