Geoprocessing Tool (Line Of Sight) not working because of wrong input datatype

529
4
01-17-2024 05:47 AM
Labels (1)
radimbachb
New Contributor III

Dear Esri community

I'd like to do Line Of Sight Queries from ArcGIS Runtime via a Geoprocessing Tool on a local server. I'm using ArcGISQtSDK 200.2.0.1 and rcGISPro 3.1.3. In ArcGIS Pro I use this tool Line Of Sight (3D Analyst)—ArcGIS Pro | Documentation to do a Line Of Sight query. From the result I created a .gpkx for the local server.
 
The local server reports following error when I use the Line Of Sight tool from ArcGIS Runtime:

 

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 documentation mentioned above).  It expects a datatype GPFeatureLayer.
The dataset mentioned in the error looks like:

 

{
    "features": [
        {
            "attributes": {
                "ObjectID": 1
            },
            "geometry": {
                "paths": [
                    [
                        [
                            912464.4710000008,
                            5948732.0405
                        ],
                        [
                            935803.3581999987,
                            5958361.371600002
                        ]
                    ]
                ],
                "spatialReference": {
                    "latestWkid": 3857,
                    "wkid": 102100
                }
            }
        }
    ],
    "fields": [
        {
            "editable": false,
            "length": 0,
            "name": "ObjectID",
            "nullable": false,
            "type": "esriFieldTypeOID"
        }
    ],
    "geometryType": "esriGeometryPolyline",
    "hasM": false,
    "hasZ": false,
    "spatialReference": {
        "latestWkid": 3857,
        "wkid": 102100
    }
}

 

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();

 

How can I figure out what is missing from the input? What data format is exactly expected? How can I create a correct GPFeatureLayer input?
 
Many thanks!
0 Kudos
4 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

Try to create FeatureLayer from inputFeatures. 

 

0 Kudos
radimbachb
New Contributor III

Thank you for the reply

I'm afraid I'm not sure I understand. Creating a FeatureLayer from a FeatureCollectionTable is not possible, as the documentation states. I tried to create a FeatureCollectionLayer, but I'm not sure what to do with it. I can not pass it to any GeoprocessingParameter as input since none are compatible.

Interestingly enough, when navigating to the task on the local server it says it expects a GPString, I assume the GeoprocessingFeature that I use as input is converted to a GPString automatically. But I'm not sure how I could do the same with a FeatureLayer.

radimbachb_0-1705571398342.png

 

0 Kudos
GKmieliauskas
Esri Regular Contributor

Yes, you are right I have checked inheritance of FeatureCollectionTable, but didn't read until the end.

FeatureCollectionLayer may not help you too.

What do you think about changing your package and send coordinates of the path as json or geojson string?

You will need to add additional geoprocessing step to package content for converting json/geojson string to features. 

radimbachb
New Contributor III

Thank you for the reply. I haven't tried your idea with the json conversion tool yet, but thanks to your reply I looked a bit more into how to create your own model in ArcGIS Pro since I've never done that before.

What I came up with is using two tools in sequence. First `Construct Sight Lines`, its output is of type ` Feature Class`, so that should be a match. The resulting sight line is the input for the Line Of Sight tool. 

radimbachb_0-1705941405036.png

Now all I have to provide from the runtime are 1 target point, 1 observer point, and the input elevation raster.

Not sure if this is the optimal solution, or if this is really necessary just to use the Line Of Sight tool. Maybe it would be simpler with the json conversion tool, I'll try that later.

0 Kudos