Fix viewshed_geo_processing for ArcGIS SDK v300

- Changed QList<Field>() to {} for Field type compatibility
- Updated signal connection from jobStatusChanged to statusChanged
- Changed addFeature() to addFeatureAsync() with QFutureWatcher pattern
- Removed ACRGIS_VERSION guards (Qt6/SDK v300 only)
- Added QFutureWatcher<void> m_addFeatureWatcher member to header

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
torstenandCopilot committed 2026-10-13 14:36:47 +02:00
1 parent 197a1ce998
commit e581d1e91c
2 files changed
+14 -24

No files matched your search

@@ -152,7 +152,7 @@ bool ViewshedGeoProcessing::execute(const QPointF &viewshedPoint_map, double out
// Create a new feature collection table based upon point geometries using the current map view spatial reference // Create a new feature collection table based upon point geometries using the current map view spatial reference
Esri::ArcGISRuntime::FeatureCollectionTable *inputFeatures = Esri::ArcGISRuntime::FeatureCollectionTable *inputFeatures =
new Esri::ArcGISRuntime::FeatureCollectionTable(QList<Esri::ArcGISRuntime::Field>() new Esri::ArcGISRuntime::FeatureCollectionTable({}
, Esri::ArcGISRuntime::GeometryType::Point , Esri::ArcGISRuntime::GeometryType::Point
, m_srMap , m_srMap
, this); , this);
@@ -163,16 +163,15 @@ bool ViewshedGeoProcessing::execute(const QPointF &viewshedPoint_map, double out
// Assign a physical location to the new point feature based upon where the user clicked on the map view // Assign a physical location to the new point feature based upon where the user clicked on the map view
inputFeature->setGeometry(esriViewshedPoint); inputFeature->setGeometry(esriViewshedPoint);
// connect to addFeature status changed signal // Add the new feature with (x,y) location to the feature collection table (SDK v300: addFeatureAsync returns QFuture<void>)
connect(inputFeatures, &Esri::ArcGISRuntime::FeatureCollectionTable::addFeatureCompleted, this, [this, inputFeatures, outerRadius, observerOffset](QUuid, bool success) QFuture<void> addFeatureFuture = inputFeatures->addFeatureAsync(inputFeature);
// Use QFutureWatcher to monitor addFeature completion
auto *addFeatureWatcher = new QFutureWatcher<void>(this);
connect(addFeatureWatcher, &QFutureWatcher<void>::finished, this, [this, inputFeatures, outerRadius, observerOffset, addFeatureWatcher]()
{ {
INFO_LOG(m_logger) << LOGFUNCTION << " addFeatureCompleted..."; addFeatureWatcher->deleteLater();
INFO_LOG(m_logger) << LOGFUNCTION << " addFeatureAsync completed...";
if (!success)
{
ERROR_LOG(m_logger) << LOGFUNCTION << " no success";
return;
}
// Create the parameters that are passed to the used geoprocessing task // Create the parameters that are passed to the used geoprocessing task
Esri::ArcGISRuntime::GeoprocessingParameters viewshedParameters = Esri::ArcGISRuntime::GeoprocessingParameters viewshedParameters =
@@ -223,15 +222,8 @@ bool ViewshedGeoProcessing::execute(const QPointF &viewshedPoint_map, double out
// Handle errors of GeoprocessingJob: // Handle errors of GeoprocessingJob:
connect(m_viewshedJob, &Esri::ArcGISRuntime::GeoprocessingJob::errorOccurred, this, &ViewshedGeoProcessing::onErrorOccuredGeoprocessingJob); connect(m_viewshedJob, &Esri::ArcGISRuntime::GeoprocessingJob::errorOccurred, this, &ViewshedGeoProcessing::onErrorOccuredGeoprocessingJob);
// Create signal handler for the job // Create signal handler for the job (SDK v300 uses statusChanged)
#if ACRGIS_VERSION >= 0x640E00 // 100.14.0
// since V100.14
connect(m_viewshedJob, &Esri::ArcGISRuntime::GeoprocessingJob::statusChanged, this, &ViewshedGeoProcessing::onJobStatusChangedWithJsParameter); connect(m_viewshedJob, &Esri::ArcGISRuntime::GeoprocessingJob::statusChanged, this, &ViewshedGeoProcessing::onJobStatusChangedWithJsParameter);
#else
// until V100.14:
connect(m_viewshedJob, &Esri::ArcGISRuntime::GeoprocessingJob::jobStatusChanged, this, &ViewshedGeoProcessing::onJobStatusChanged);
#endif // ACRGIS_VERSION
// start the job // start the job
@@ -241,8 +233,7 @@ bool ViewshedGeoProcessing::execute(const QPointF &viewshedPoint_map, double out
ERROR_LOG(m_logger) << LOGFUNCTION << " viewshedJob->start() failed"; ERROR_LOG(m_logger) << LOGFUNCTION << " viewshedJob->start() failed";
}); });
// Add the new feature with (x,y) location to the feature collection table addFeatureWatcher->setFuture(addFeatureFuture);
inputFeatures->addFeature(inputFeature);
TRACE_LOG(m_logger) << LOGFUNCTION << " END" << " m_viewshedInProgress=" << m_viewshedInProgress; TRACE_LOG(m_logger) << LOGFUNCTION << " END" << " m_viewshedInProgress=" << m_viewshedInProgress;
return true; return true;
@@ -303,14 +294,12 @@ void ViewshedGeoProcessing::onJobStatusChanged()
TRACE_LOG(m_logger) << LOGFUNCTION << " END"; TRACE_LOG(m_logger) << LOGFUNCTION << " END";
} }
#if ACRGIS_VERSION >= 0x640E00 // 100.14.0
void ViewshedGeoProcessing::onJobStatusChangedWithJsParameter(const Esri::ArcGISRuntime::JobStatus &/*newStatus*/) void ViewshedGeoProcessing::onJobStatusChangedWithJsParameter(const Esri::ArcGISRuntime::JobStatus &/*newStatus*/)
{ {
TRACE_LOG(m_logger) << LOGFUNCTION << " START"; TRACE_LOG(m_logger) << LOGFUNCTION << " START";
onJobStatusChanged(); onJobStatusChanged();
TRACE_LOG(m_logger) << LOGFUNCTION << " END"; TRACE_LOG(m_logger) << LOGFUNCTION << " END";
} }
#endif // ACRGIS_VERSION
bool ViewshedGeoProcessing::processResults(Esri::ArcGISRuntime::GeoprocessingResult *results) bool ViewshedGeoProcessing::processResults(Esri::ArcGISRuntime::GeoprocessingResult *results)
@@ -20,6 +20,7 @@
#include <QObject> #include <QObject>
#include <QColor> #include <QColor>
#include <QPointF> #include <QPointF>
#include <QFutureWatcher>
// forward: // forward:
namespace Esri namespace Esri
@@ -79,9 +80,7 @@ public:
protected slots: protected slots:
void onJobStatusChanged(); void onJobStatusChanged();
#if ACRGIS_VERSION >= 0x640E00 // 100.14.0
void onJobStatusChangedWithJsParameter(const Esri::ArcGISRuntime::JobStatus &); void onJobStatusChangedWithJsParameter(const Esri::ArcGISRuntime::JobStatus &);
#endif // ACRGIS_VERSION
void onErrorOccuredGeoprocessingTask(const Esri::ArcGISRuntime::Error &error); void onErrorOccuredGeoprocessingTask(const Esri::ArcGISRuntime::Error &error);
void onErrorOccuredGeoprocessingJob(const Esri::ArcGISRuntime::Error &error); void onErrorOccuredGeoprocessingJob(const Esri::ArcGISRuntime::Error &error);
@@ -113,6 +112,8 @@ private:
Esri::ArcGISRuntime::Graphic *m_originGraphic = nullptr; Esri::ArcGISRuntime::Graphic *m_originGraphic = nullptr;
Esri::ArcGISRuntime::Graphic *m_extentGraphic = nullptr; Esri::ArcGISRuntime::Graphic *m_extentGraphic = nullptr;
QFutureWatcher<void> m_addFeatureWatcher;
LOGGER_T m_logger; LOGGER_T m_logger;
}; // class ViewshedGeoProcessing }; // class ViewshedGeoProcessing