Select to view content in your preferred language

How to extract the features(Line, Point) from the result that is outputted in Arcgis Local Server - Line of Sight Geoprocessing Tool

780
2
11-29-2023 01:44 AM
Labels (4)
KadirTuna
New Contributor


Hello Dear Residents,

I'm using Arcgis Runtime .NET in my WPF Application to create the Arcgis Local Server and to use the Line of Sight Geoprocessing Tool Service. Eventhough the local server succesfully runs and outputs the result. , I couldn't extract the features like "the obstruction point" or "line" from it.

 

"
string gpServiceResultUrl = _localGeoprocessingService.Url.ToString();
gpServiceResultUrl = gpServiceResultUrl.Replace("GPServer", jobSegment);
_gpServiceResultUrl = gpServiceResultUrl;

// Create a map image layer to show the results
ArcGISMapImageLayer myMapImageLayer = new ArcGISMapImageLayer(new Uri(gpServiceResultUrl));

"

- The object that should have the "Output Obstruction Point Feature Class" above. 

ArcgisProGP.PNG

- The result outputted by Line of Sight GP in Arcgis Pro and that's what I want in my WPF app too.

Arcgis.PNG

- It's demonstrated result of the Line of Sight Geoprocessing tool of Arcgis Local Server on a map in a WPF App.

1 -  The result is an object of "ArcGISMapImageLayer" as you know. Could you please explain me how to Extract the feature class in Arcgis Runtime .NET?

For example; I should learn the obstruction point's coordinate. 

2 - If I use the same Geoprocessing Tool in Arcgis Pro. The result would have VisCode which shows the "Visible" line with green color and "Not Visible" line with red color. As you see in the image above, there is just one color that is not specify any meaning in the lines. How to provide the geoprocessing tool in arcgis local server to create the result with VisCode?

Thank you for helping. 

 

Best regards,

 

 

0 Kudos
2 Replies
AlexanderZhang
New Contributor III

Hi,@KadirTuna i have used a geoprocessing package executed with Local Server, here are some of my suggestions.

You can directly get the results:

IFeatures? features = null;
GeoprocessingResult results = await _gpJob.GetResultAsync();
var result1 = results.Outputs.Values.FirstOrDefault() as GeoprocessingFeatures;
if(result1.CanGetOutputFeatures)
	features = await result1.GetOutputFeatures;
else
	features = result1.Features;

Another way to  get and display the results is

 // Convert geoprocessor server url to that of a map server and get the job id.
                Uri serviceUrl = _localGPService.Url;
                string mapServerUrl = serviceUrl.ToString().Replace("GPServer", "MapServer/jobs/" + _gpJob.ServerJobId);

                // Create a service geodatabase from the map server url.
                var serviceGeodatabase = new ServiceGeodatabase(new Uri(mapServerUrl));

                // Load the service geodatabase.
                await serviceGeodatabase.LoadAsync();

                // Get the feature table from the service geodatabase.
                FeatureTable featureTable = serviceGeodatabase.GetTable(0);

                // Instantiate the elevation profile feature layer from the feature table.
                _elevationProfileFeatureLayer = new FeatureLayer(featureTable);

                // Load the elevation profile feature layer.
                await _elevationProfileFeatureLayer.LoadAsync();

                // Set the surface placement and renderer for the elevation profile feature layer.
                _elevationProfileFeatureLayer.SceneProperties.SurfacePlacement = SurfacePlacement.Absolute;
                _elevationProfileFeatureLayer.Renderer = new SimpleRenderer(new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.White, 3));

 

You can refer to the code sample Generate elevation profile with Local Server !

 

Thanks

 

 

0 Kudos
radimbachb
New Contributor III

@KadirTuna 

Sorry for being off topic a bit. I'm also trying to do Line Of Sight queries, but I'm having issues with defining the input the correct way. I created the .gpkx from this tool: Line Of Sight (3D Analyst)—ArcGIS Pro | Documentation

I create this input this way:

 

FeatureCollectionTable* inputFeatures =
	new FeatureCollectionTable(QList<Field>(), GeometryType::Polyline, SpatialReference::webMercator(), this);
Feature* lineFeature = inputFeatures->createFeature(this);

auto observerPoint = static_cast<Point>(m_observerGraphic->geometry());
auto targetPoint = static_cast<Point>(m_targetGraphic->geometry());
auto polylineBuilder = new PolylineBuilder(SpatialReference::webMercator(), this);
polylineBuilder->addPoint(observerPoint);
polylineBuilder->addPoint(targetPoint);
auto polyLine = polylineBuilder->toPolyline();
lineFeature->setGeometry(polyLine);

inputFeatures->addFeatureAsync(lineFeature).then(this, [this, inputFeatures]() {
	onAddFeatureCompleted_(inputFeatures);
});

 

Then in onAddFeatureCompleted_:

 

GeoprocessingParameters geoprocessParams = GeoprocessingParameters(GeoprocessingExecutionType::AsynchronousSubmit);

geoprocessParams.setOutputSpatialReference(SpatialReference::webMercator());

QMap<QString, GeoprocessingParameter*> inputs;
inputs["in_line_feature_class"] =
	new GeoprocessingFeatures(inputFeatures, this);
QString dataPath = QDir::homePath() + "/ArcGIS/Runtime/Data";
inputs["in_surface"] =
	new GeoprocessingRaster(QUrl(dataPath + "/raster/SwissElevation/Elevation.tif"), ".tif", this);
geoprocessParams.setInputs(inputs);

GeoprocessingJob* geoprocessJob = m_gpTask->createJob(geoprocessParams);
geoprocessJob->start();

However, the local server reports following error when I run the task:

 

Server job has failed. ERROR 000811: The value is not a feature class.
ERROR 000732: Input Line Features: Dataset [...] does not exist or is not supported.

 

The input causing the error is named "in_line_feature_class" (see Line Of Sight (3D Analyst)—ArcGIS Pro | Documentation).  It expects a datatype GPFeatureLayer, but I'm not sure how I can create it correctly from the ArcGIS Runtime SDK... Maybe you have a code snippet ready that you could share? Many thanks!

 

0 Kudos