本文整理汇总了C#中Geoprocessor.SubmitJobAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Geoprocessor.SubmitJobAsync方法的具体用法?C# Geoprocessor.SubmitJobAsync怎么用?C# Geoprocessor.SubmitJobAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Geoprocessor
的用法示例。
在下文中一共展示了Geoprocessor.SubmitJobAsync方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 MyMapView.Editor.RequestPointAsync();
//update UI elements
MyProgressRing.Visibility = Windows.UI.Xaml.Visibility.Visible;
MyProgressRing.IsActive = true;
viewshedLayer.Graphics.Clear();
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 viewshedResult = await task.GetResultDataAsync(result.JobID, "View") as GPFeatureRecordSetLayer;
var rangeResult = await task.GetResultDataAsync(result.JobID, "Range") as GPFeatureRecordSetLayer;
if (viewshedResult != null && viewshedResult.FeatureSet != null && viewshedResult.FeatureSet.Features != null)
{
foreach (var feature in viewshedResult.FeatureSet.Features)
{
viewshedLayer.Graphics.Add((Graphic)feature);
}
}
//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: StartGP_Click
private async void StartGP_Click(object sender, RoutedEventArgs e)
{
StartGP.IsEnabled = false;
ClearGraphics();
ClearButton.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
ProcessingTextBlock.Visibility = Visibility.Collapsed;
var inputPolyline = await mapView1.Editor.RequestShapeAsync(DrawShape.Polyline);
var inputGraphic = new Graphic { Geometry = inputPolyline };
GraphicsLayer inputLayer = mapView1.Map.Layers["InputLayer"] as GraphicsLayer;
inputLayer.Graphics.Add(inputGraphic);
MyProgressRing.Visibility = Visibility.Visible;
MyProgressRing.IsActive = true;
string message = null;
Geoprocessor task = new Geoprocessor(new Uri(ServiceUri));
var inputParameter = new GPInputParameter();
inputParameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Features", inputPolyline));
inputParameter.GPParameters.Add(new GPLinearUnit("Linear_unit", LinearUnits.Miles, Int32.Parse(DistanceTextBox.Text)));
try
{
//Submit the job and await the results
var gpJobInfo = await task.SubmitJobAsync(inputParameter);
//Poll the server every 5 seconds for the status of the job.
//Cancelled, Cancelling, Deleted, Deleting, Executing, Failed, New, Submitted, Succeeded, TimedOut, Waiting
while (gpJobInfo.JobStatus != GPJobStatus.Cancelled &&
gpJobInfo.JobStatus != GPJobStatus.Deleted &&
gpJobInfo.JobStatus != GPJobStatus.Failed &&
gpJobInfo.JobStatus != GPJobStatus.Succeeded &&
gpJobInfo.JobStatus != GPJobStatus.TimedOut)
{
gpJobInfo = await task.CheckJobStatusAsync(gpJobInfo.JobID);
await Task.Delay(5000);
}
//Now that the job is completed, check whether the service returned the results as Features or as a GPResultImageLayer.
//This can happen if the number of features to return exceeds the limit set on the service
if (gpJobInfo.JobStatus == GPJobStatus.Succeeded)
{
var resultData = await task.GetResultDataAsync(gpJobInfo.JobID, "Clipped_Counties");
if (resultData is GPFeatureRecordSetLayer)
{
GPFeatureRecordSetLayer gpLayer = resultData as GPFeatureRecordSetLayer;
if (gpLayer.FeatureSet.Features.Count == 0)
{
var resultImageLayer = await task.GetResultImageLayerAsync(gpJobInfo.JobID, "Clipped_Counties");
GPResultImageLayer gpImageLayer = resultImageLayer;
gpImageLayer.Opacity = 0.5;
mapView1.Map.Layers.Add(gpImageLayer);
ProcessingTextBlock.Visibility = Visibility.Visible;
ProcessingTextBlock.Text = "Greater than 500 features returned. Results drawn using map service.";
return;
}
GraphicsLayer resultLayer = mapView1.Map.Layers["MyResultGraphicsLayer"] as GraphicsLayer;
foreach (Graphic g in gpLayer.FeatureSet.Features)
{
resultLayer.Graphics.Add(g);
}
}
}
MyProgressRing.Visibility = Visibility.Collapsed;
MyProgressRing.IsActive = false;
ClearButton.Visibility = Visibility.Visible;
StartGP.IsEnabled = true;
}
catch (Exception ex)
{
message = ex.Message;
}
if (message != null)
await new MessageDialog(message, "GP Failed").ShowAsync();
}
示例3: MyDrawObject_DrawComplete
private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
{
MyDrawObject.IsEnabled = false;
ProcessingTextBlock.Visibility = Visibility.Visible;
_processingTimer.Start();
GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
Graphic graphic = new Graphic()
{
Symbol = LayoutRoot.Resources["ClipLineSymbol"] as ESRI.ArcGIS.Client.Symbols.LineSymbol,
Geometry = args.Geometry
};
graphicsLayer.Graphics.Add(graphic);
Geoprocessor geoprocessorTask = new Geoprocessor("http://serverapps10.esri.com/ArcGIS/rest/services/" +
"SamplesNET/USA_Data_ClipTools/GPServer/ClipCounties");
//geoprocessorTask.ProxyURL = "http://servicesbeta3.esri.com/SilverlightDemos/ProxyPage/proxy.ashx";
geoprocessorTask.UpdateDelay = 5000;
geoprocessorTask.JobCompleted += GeoprocessorTask_JobCompleted;
List<GPParameter> parameters = new List<GPParameter>();
parameters.Add(new GPFeatureRecordSetLayer("Input_Features", args.Geometry));
parameters.Add(new GPLinearUnit("Linear_unit", esriUnits.esriMiles, Int32.Parse(DistanceTextBox.Text)));
geoprocessorTask.SubmitJobAsync(parameters);
}
示例4: RunButton_Click
private void RunButton_Click(object sender, RoutedEventArgs e)
{
try
{
if (_graphicsLayer.Graphics.Count > 0)
{
Geoprocessor gpAircraftRouteGen = new Geoprocessor(_serviceURL);
gpAircraftRouteGen.JobCompleted += gpAircraftRouteGen_JobCompleted;
gpAircraftRouteGen.Failed += gpAircraftRouteGen_Failed;
List<GPParameter> parameters = new List<GPParameter>();
FeatureSet pFeatures = new FeatureSet(_graphicsLayer.Graphics);
parameters.Add(new GPFeatureRecordSetLayer("Route_Definition", pFeatures));
parameters.Add(new GPString("Aircraft_Model", aircraftmodel.Text));
parameters.Add(new GPDouble("Time_Step__s_", System.Convert.ToDouble(timestep.Text)));
string[] theTimevals = startTime.Text.Split(' ');
string[] theTime = theTimevals[0].Split(':');
int hour = 0;
int minute = 0;
int seconds = 0;
if (theTimevals[1] == "PM")
hour = System.Convert.ToInt16(theTime[0]) + 12;
else
hour = System.Convert.ToInt16(theTime[0]);
minute = System.Convert.ToInt16(theTime[1]);
seconds = System.Convert.ToInt16(theTime[2]);
DateTime start;
if (StartDate.SelectedDate == null)
start = new DateTime(StartDate.DisplayDate.Date.Year, StartDate.DisplayDate.Date.Month, StartDate.DisplayDate.Date.Day, hour, minute, seconds);
else
start = new DateTime(StartDate.SelectedDate.Value.Date.Year, StartDate.SelectedDate.Value.Date.Month, StartDate.SelectedDate.Value.Date.Day, hour, minute, seconds);
string[] theTimevalsStop = stopTime.Text.Split(' ');
string[] theTimeStop = theTimevalsStop[0].Split(':');
if (theTimevalsStop[1] == "PM")
hour = System.Convert.ToInt16(theTimeStop[0]) + 12;
else
hour = System.Convert.ToInt16(theTimeStop[0]);
minute = System.Convert.ToInt16(theTimeStop[1]);
seconds = System.Convert.ToInt16(theTimeStop[2]);
DateTime stop;
if (StopDate.SelectedDate == null)
stop = new DateTime(StopDate.DisplayDate.Date.Year, StopDate.DisplayDate.Date.Month, StopDate.DisplayDate.Date.Day, hour, minute, seconds);
else
stop = new DateTime(StopDate.SelectedDate.Value.Date.Year, StopDate.SelectedDate.Value.Date.Month, StopDate.SelectedDate.Value.Date.Day, hour, minute, seconds);
parameters.Add(new GPDate("Start_Time__UTC_", start.ToUniversalTime()));
parameters.Add(new GPDate("Stop_Time__UTC_", stop.ToUniversalTime()));
//gpAircraftRouteGen.OutputSpatialReference = new SpatialReference(102100);
gpAircraftRouteGen.OutputSpatialReference = new SpatialReference(4326);
gpAircraftRouteGen.SubmitJobAsync(parameters);
if (_mapWidget != null)
{
_mapWidget.Map.MouseClick -= Map_MouseClick;
}
}
}
catch
{
System.Diagnostics.Debug.WriteLine("error");
}
}
示例5: RunButton_Click
private void RunButton_Click(object sender, RoutedEventArgs e)
{
try
{
Geoprocessor gpAircraftComms = new Geoprocessor(_serviceURL);
gpAircraftComms.JobCompleted += gpAircraftComms_JobCompleted;
gpAircraftComms.Failed += gpAircraftComms_Failed;
List<GPParameter> parameters = new List<GPParameter>();
FeatureSet pFeatures = new FeatureSet(_graphicsLayer.Graphics);
parameters.Add(new GPFeatureRecordSetLayer("Waypoints", pFeatures));
parameters.Add(new GPString("Aircraft_Model", aircraftmodel.Text));
FeatureSet pPolygon = new FeatureSet(_graphicsLayerPoly.Graphics);
parameters.Add(new GPFeatureRecordSetLayer("AreaTarget", pPolygon));
parameters.Add(new GPDouble("Grid_Point_Granularity__deg_", System.Convert.ToDouble(gridgranularity.Text)));
string[] theTimevals = startTime.Text.Split(' ');
string[] theTime = theTimevals[0].Split(':');
int hour = 0;
int minute = 0;
int seconds = 0;
if (theTimevals[1] == "PM")
hour = System.Convert.ToInt16(theTime[0]) + 12;
else
hour = System.Convert.ToInt16(theTime[0]);
minute = System.Convert.ToInt16(theTime[1]);
seconds = System.Convert.ToInt16(theTime[2]);
DateTime start;
if (StartDate.SelectedDate == null)
start = new DateTime(StartDate.DisplayDate.Date.Year, StartDate.DisplayDate.Date.Month, StartDate.DisplayDate.Day, hour, minute, seconds);
else
start = new DateTime(StartDate.SelectedDate.Value.Date.Year, StartDate.SelectedDate.Value.Date.Month, StartDate.SelectedDate.Value.Date.Day, hour, minute, seconds);
string[] theTimevalsStop = stopTime.Text.Split(' ');
string[] theTimeStop = theTimevalsStop[0].Split(':');
if (theTimevalsStop[1] == "PM")
hour = System.Convert.ToInt16(theTimeStop[0]) + 12;
else
hour = System.Convert.ToInt16(theTimeStop[0]);
minute = System.Convert.ToInt16(theTimeStop[1]);
seconds = System.Convert.ToInt16(theTimeStop[2]);
DateTime stop;
if (StopDate.SelectedDate == null)
stop = new DateTime(StopDate.DisplayDate.Year, StopDate.DisplayDate.Month, StopDate.DisplayDate.Day, hour, minute, seconds);
else
stop = new DateTime(StopDate.SelectedDate.Value.Date.Year, StopDate.SelectedDate.Value.Date.Month, StopDate.SelectedDate.Value.Date.Day, hour, minute, seconds);
parameters.Add(new GPDate("Start_Time__UTC_", start.ToUniversalTime()));
parameters.Add(new GPDate("Stop_Time__UTC_", stop.ToUniversalTime()));
gpAircraftComms.ProcessSpatialReference = new SpatialReference(4326);
gpAircraftComms.SubmitJobAsync(parameters);
if (_mapWidget != null)
{
_mapWidget.Map.MouseClick -= Map_MouseClick;
}
}
catch (Exception ex)
{
MessageBox.Show("Error in run: " + ex.Message);
}
}
示例6: getInputLineAndClip
// Waits for the user to draw a line, then performs the buffer and clip operation
private async void getInputLineAndClip()
{
if (m_firstPointAdded)
return;
// Get line from user
var clipLine = await Editor.RequestShapeAsync(DrawShape.Polyline,
new SimpleLineSymbol() { Color = Colors.Red, Width = 2, Style = SimpleLineStyle.Dash });
ClipLines.Add(new Graphic() { Geometry = clipLine });
// Show busy UI
BusyVisibility = Visibility.Visible;
StatusText = "Executing...";
string error = null;
// Initialize the Geoprocessing task with the buffer and clip service endpoint
Geoprocessor task = new Geoprocessor(new Uri("http://serverapps10.esri.com/ArcGIS/rest/services/SamplesNET/" +
"USA_Data_ClipTools/GPServer/ClipCounties"));
// Initialize input parameters
var parameter = new GPInputParameter()
{
OutSpatialReference = SpatialReferences.WebMercator
};
parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Features", clipLine)); // input geometry
parameter.GPParameters.Add(new GPLinearUnit("Linear_unit", LinearUnits.Miles, BufferDistance)); // buffer distance
try
{
// Submit the job and await the results
var result = await task.SubmitJobAsync(parameter);
// Poll the server every two seconds for the status of the job.
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
var resultData = await task.GetResultDataAsync(result.JobID, "Clipped_Counties");
if (resultData is GPFeatureRecordSetLayer)
{
GPFeatureRecordSetLayer resultsLayer = resultData as GPFeatureRecordSetLayer;
if (resultsLayer.FeatureSet != null
&& resultsLayer.FeatureSet.Features != null
&& resultsLayer.FeatureSet.Features.Count != 0)
{
// Results were returned as graphics. Add them to the ClippedCounties collection
ClippedCounties = new ObservableCollection<Graphic>(resultsLayer.FeatureSet.Features);
}
else // Try to get results as a GPResultImageLayer
{
StatusText = "Clip operation complete. Retrieving results...";
m_clippedCountiesLayer = await task.GetResultImageLayerAsync(result.JobID, "Clipped_Counties");
// If successful, add the layer to the layers collection
if (m_clippedCountiesLayer != null)
{
m_clippedCountiesLayer.Opacity = 0.5;
// Insert the layer below the input layer
Layers.Insert(Layers.IndexOf(m_clipLinesLayer), m_clippedCountiesLayer);
// Wait until the result layer is initialized
await m_clippedCountiesLayer.InitializeAsync();
}
else
{
error = "No results found";
}
}
}
else
{
error = "Clip operation failed";
}
}
else
{
error = "Clip operation failed";
}
}
catch (Exception ex)
{
//.........这里部分代码省略.........
示例7: 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;
}
}
示例8: 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 = "";
}
示例9: RunButton_Click
private void RunButton_Click(object sender, RoutedEventArgs e)
{
try
{
Geoprocessor gpGroundComCov = new Geoprocessor(_serviceURL);
gpGroundComCov.JobCompleted += gpGroundComCov_JobCompleted;
gpGroundComCov.Failed += gpGroundComCov_Failed;
List<GPParameter> parameters = new List<GPParameter>();
FeatureSet pFeatures = new FeatureSet(_graphicsLayer.Graphics);
parameters.Add(new GPFeatureRecordSetLayer("FOBPoint", pFeatures));
gpGroundComCov.ProcessSpatialReference = new SpatialReference(4326);
gpGroundComCov.SubmitJobAsync(parameters);
if (_mapWidget != null)
{
_mapWidget.Map.MouseClick -= Map_MouseClick;
}
}
catch (Exception ex)
{
MessageBox.Show("Error during run: " + ex.Message);
}
}
示例10: btnSolve_Click
// ***********************************************************************************
// * ...Execute Placard of ERG Chemical GP Tool
// ***********************************************************************************
private void btnSolve_Click(object sender, RoutedEventArgs e)
{
try
{
if (_spillLocationGraphicsLayer.Graphics.Count > 0)
{
Geoprocessor geoprocessorTask = new Geoprocessor();
if (cmbChemicalOrPlacardType.SelectedValue == null)
{
MessageBox.Show("Check your material or placard type!", "Error");
return;
}
var materialType = cmbChemicalOrPlacardType.SelectedValue.ToString();
var spillTime = cmbSpillTime.SelectedValue.ToString();
var spillSize = cmbSpillSize.SelectedValue.ToString();
var windDir = Convert.ToInt32(windDirection.Value);
List<GPParameter> parameters = new List<GPParameter>();
parameters.Add(new GPFeatureRecordSetLayer("in_features", new FeatureSet(_spillLocationGraphicsLayer.Graphics)));
if (cmbChemicalorPlacard.SelectedValue.ToString() == "Chemical")
{
geoprocessorTask.Url = _chemicalURL;
parameters.Add(new GPString("material_type", materialType));
geoprocessorTask.JobCompleted += ergChemicalGeoprocessorTask_JobCompleted;
}
else
{
geoprocessorTask.Url = _placardURL;
geoprocessorTask.JobCompleted += ergPlacardGeoprocessorTask_JobCompleted;
parameters.Add(new GPString("placard_id", materialType));
}
geoprocessorTask.OutputSpatialReference = _mapWidget.Map.SpatialReference;
geoprocessorTask.ProcessSpatialReference = _mapWidget.Map.SpatialReference;
if (_windDirectionQuestionResult == MessageBoxResult.No)
parameters.Add(new GPLong("wind_bearing", windDir));
else
parameters.Add(new GPLong("wind_bearing", _windDirectionTo));
parameters.Add(new GPString("time_of_day", spillTime));
parameters.Add(new GPString("spill_size", spillSize));
if (_gpExecutionType == "esriExecutionTypeSynchronous")
{
geoprocessorTask.ExecuteCompleted += ERGGeoprocessorTask_ExecuteCompleted;
geoprocessorTask.Failed += GeoprocessorTask_Failed;
geoprocessorTask.ExecuteAsync(parameters);
}
else
geoprocessorTask.SubmitJobAsync(parameters);
}
else
MessageBox.Show("Please add spill location on the map", "Error");
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
return;
}
}
示例11: RunButton_Click_1
private void RunButton_Click_1(object sender, RoutedEventArgs e)
{
try
{
if (_graphicsLayer.Graphics.Count > 0)
{
//Geoprocessor gpFarthest = new Geoprocessor("http://dtcrugmo01.esri.com:6080/arcgis/rest/services/Tasks/FarthestOnCircle/GPServer/Farthest%20On%20Circle");
Geoprocessor gpFarthest = new Geoprocessor(_serviceURL);
gpFarthest.JobCompleted += gpFarthest_JobCompleted;
gpFarthest.Failed += gpFarthest_Failed;
List<GPParameter> parameters = new List<GPParameter>();
FeatureSet pFeatures = new FeatureSet(_graphicsLayer.Graphics);
parameters.Add(new GPFeatureRecordSetLayer("Position_Last_Seen", pFeatures));
parameters.Add(new GPString("Range_for_Analysis_in_Nautical_Miles", Range.Text));
parameters.Add(new GPString("Average_Speed_in_Knots__kts__for_Analysis", Speed.Text));
gpFarthest.OutputSpatialReference = new SpatialReference(102100);
gpFarthest.SubmitJobAsync(parameters);
if (_mapWidget != null)
{
_mapWidget.Map.MouseClick -= Map_MouseClick;
}
}
}
catch
{
System.Diagnostics.Debug.WriteLine("error");
}
}