本文整理汇总了C#中Geoprocessor.GetResultMapServiceLayer方法的典型用法代码示例。如果您正苦于以下问题:C# Geoprocessor.GetResultMapServiceLayer方法的具体用法?C# Geoprocessor.GetResultMapServiceLayer怎么用?C# Geoprocessor.GetResultMapServiceLayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Geoprocessor
的用法示例。
在下文中一共展示了Geoprocessor.GetResultMapServiceLayer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartButton_Click
private async void StartButton_Click(object sender, RoutedEventArgs e)
{
StartButton.IsEnabled = false;
ClearResultsButton.Visibility = Visibility.Collapsed;
//get the user's input point
var inputPoint = await mapView1.Editor.RequestPointAsync();
//update UI elements
MyProgressRing.Visibility = Windows.UI.Xaml.Visibility.Visible;
MyProgressRing.IsActive = true;
inputLayer.Graphics.Clear();
inputLayer.Graphics.Add(new Graphic() { Geometry = inputPoint });
Geoprocessor task = new Geoprocessor(new Uri("http://serverapps101.esri.com/arcgis/rest/services/ProbabilisticViewshedModel/GPServer/ProbabilisticViewshedModel"));
var parameter = new GPInputParameter()
{
OutSpatialReference = new SpatialReference(102100)
};
parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Features", inputPoint));
parameter.GPParameters.Add(new GPString("Height", HeightTextBox.Text));
parameter.GPParameters.Add(new GPLinearUnit("Distance", LinearUnits.Miles, Convert.ToDouble(MilesTextBox.Text)));
var result = await task.SubmitJobAsync(parameter);
//Poll the server for results every 2 seconds.
while (result.JobStatus != GPJobStatus.Cancelled && result.JobStatus != GPJobStatus.Deleted &&
result.JobStatus != GPJobStatus.Succeeded && result.JobStatus != GPJobStatus.TimedOut)
{
result = await task.CheckJobStatusAsync(result.JobID);
//show the status
StatusTextBlock.Text = string.Join(Environment.NewLine, result.Messages.Select(x => x.Description));
await Task.Delay(2000);
}
if (result.JobStatus == GPJobStatus.Succeeded)
{
//get the results as a ArcGISDynamicMapServiceLayer
StatusTextBlock.Text = "Finished processing. Retrieving results...";
var resultLayer = task.GetResultMapServiceLayer(result.JobID);
if (resultLayer != null)
{
//Add an ID so that we can reference this layer (to remove it)
resultLayer.ID = "MyResultsLayer";
//Insert the results layer just beneath the input graphics layer.
//This allows us to see the input point at all times.
mapView1.Map.Layers.Insert(mapView1.Map.Layers.IndexOf(inputLayer), resultLayer);
}
//Reset the UI
StatusTextBlock.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
StartButton.IsEnabled = true;
ClearResultsButton.Visibility = Visibility.Visible;
MyProgressRing.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
MyProgressRing.IsActive = false;
}
}
示例2: mapView1_Tap
private async void mapView1_Tap(object sender, MapViewInputEventArgs e)
{
if (BusyVisibility == Visibility.Visible)
{
MessageBox.Show("Please wait until the current operation is complete.");
return;
}
// Show busy UI
BusyVisibility = Visibility.Visible;
StatusText = "Executing...";
// Clear previous results
TapPoints.Clear();
if (m_viewshedLayer != null)
Layers.Remove(m_viewshedLayer);
// Create graphic and add to tap points
var g = new Graphic() { Geometry = e.Location };
TapPoints.Add(g);
string error = null;
// Initialize the Geoprocessing task with the viewshed calculation service endpoint
Geoprocessor task = new Geoprocessor(new Uri("http://serverapps101.esri.com/ArcGIS/rest/services/" +
"ProbabilisticViewshedModel/GPServer/ProbabilisticViewshedModel"));
// Initialize input parameters
var parameter = new GPInputParameter()
{
OutSpatialReference = SpatialReferences.WebMercator
};
parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Features", e.Location));
parameter.GPParameters.Add(new GPString("Height", "50"));
parameter.GPParameters.Add(new GPLinearUnit("Distance", LinearUnits.Miles, 10));
try
{
var result = await task.SubmitJobAsync(parameter);
// Poll the server for results every two seconds.
while (result.JobStatus != GPJobStatus.Cancelled
&& result.JobStatus != GPJobStatus.Deleted
&& result.JobStatus != GPJobStatus.Failed
&& result.JobStatus != GPJobStatus.Succeeded
&& result.JobStatus != GPJobStatus.TimedOut)
{
result = await task.CheckJobStatusAsync(result.JobID);
// show the status
var descriptions = result.Messages.Select(msg => msg.Description);
var status = string.Join(Environment.NewLine, descriptions);
if (!string.IsNullOrEmpty(status))
StatusText = status;
await Task.Delay(2000);
}
if (result.JobStatus == GPJobStatus.Succeeded)
{
// get the results as a ArcGISDynamicMapServiceLayer
StatusText = "Calculation complete. Retrieving results...";
m_viewshedLayer = task.GetResultMapServiceLayer(result.JobID);
if (m_viewshedLayer != null)
{
// Insert the results layer beneath the tap points layer.
// This allows the input point to be visible at all times.
Layers.Insert(Layers.IndexOf(m_tapPointsLayer), m_viewshedLayer);
// Wait until the viewshed layer is initialized
await m_viewshedLayer.InitializeAsync();
}
else
{
error = "No results returned";
}
}
else
{
error = "Viewshed calculation failed";
}
}
catch (Exception ex)
{
error = "Viewshed calculation failed: " + ex.Message;
}
// If operation did not succeed, notify user
if (error != null)
MessageBox.Show(error);
// Hide busy UI
BusyVisibility = Visibility.Collapsed;
StatusText = "";
}