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:
1 parent
197a1ce998
commit
e581d1e91c
2 files changed
+14
-24
No files matched your search
+11
-22
@@ -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
|
||||
Esri::ArcGISRuntime::FeatureCollectionTable *inputFeatures =
|
||||
new Esri::ArcGISRuntime::FeatureCollectionTable(QList<Esri::ArcGISRuntime::Field>()
|
||||
new Esri::ArcGISRuntime::FeatureCollectionTable({}
|
||||
, Esri::ArcGISRuntime::GeometryType::Point
|
||||
, m_srMap
|
||||
, 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
|
||||
inputFeature->setGeometry(esriViewshedPoint);
|
||||
|
||||
// connect to addFeature status changed signal
|
||||
connect(inputFeatures, &Esri::ArcGISRuntime::FeatureCollectionTable::addFeatureCompleted, this, [this, inputFeatures, outerRadius, observerOffset](QUuid, bool success)
|
||||
// Add the new feature with (x,y) location to the feature collection table (SDK v300: addFeatureAsync returns QFuture<void>)
|
||||
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...";
|
||||
|
||||
if (!success)
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " no success";
|
||||
return;
|
||||
}
|
||||
addFeatureWatcher->deleteLater();
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << " addFeatureAsync completed...";
|
||||
|
||||
// Create the parameters that are passed to the used geoprocessing task
|
||||
Esri::ArcGISRuntime::GeoprocessingParameters viewshedParameters =
|
||||
@@ -223,15 +222,8 @@ bool ViewshedGeoProcessing::execute(const QPointF &viewshedPoint_map, double out
|
||||
// Handle errors of GeoprocessingJob:
|
||||
connect(m_viewshedJob, &Esri::ArcGISRuntime::GeoprocessingJob::errorOccurred, this, &ViewshedGeoProcessing::onErrorOccuredGeoprocessingJob);
|
||||
|
||||
// Create signal handler for the job
|
||||
|
||||
#if ACRGIS_VERSION >= 0x640E00 // 100.14.0
|
||||
// since V100.14
|
||||
// Create signal handler for the job (SDK v300 uses statusChanged)
|
||||
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
|
||||
@@ -241,8 +233,7 @@ bool ViewshedGeoProcessing::execute(const QPointF &viewshedPoint_map, double out
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " viewshedJob->start() failed";
|
||||
|
||||
});
|
||||
// Add the new feature with (x,y) location to the feature collection table
|
||||
inputFeatures->addFeature(inputFeature);
|
||||
addFeatureWatcher->setFuture(addFeatureFuture);
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END" << " m_viewshedInProgress=" << m_viewshedInProgress;
|
||||
return true;
|
||||
@@ -303,14 +294,12 @@ void ViewshedGeoProcessing::onJobStatusChanged()
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
#if ACRGIS_VERSION >= 0x640E00 // 100.14.0
|
||||
void ViewshedGeoProcessing::onJobStatusChangedWithJsParameter(const Esri::ArcGISRuntime::JobStatus &/*newStatus*/)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
onJobStatusChanged();
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
#endif // ACRGIS_VERSION
|
||||
|
||||
|
||||
bool ViewshedGeoProcessing::processResults(Esri::ArcGISRuntime::GeoprocessingResult *results)
|
||||
|
||||
+3
-2
@@ -20,6 +20,7 @@
|
||||
#include <QObject>
|
||||
#include <QColor>
|
||||
#include <QPointF>
|
||||
#include <QFutureWatcher>
|
||||
|
||||
// forward:
|
||||
namespace Esri
|
||||
@@ -79,9 +80,7 @@ public:
|
||||
|
||||
protected slots:
|
||||
void onJobStatusChanged();
|
||||
#if ACRGIS_VERSION >= 0x640E00 // 100.14.0
|
||||
void onJobStatusChangedWithJsParameter(const Esri::ArcGISRuntime::JobStatus &);
|
||||
#endif // ACRGIS_VERSION
|
||||
|
||||
void onErrorOccuredGeoprocessingTask(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_extentGraphic = nullptr;
|
||||
|
||||
QFutureWatcher<void> m_addFeatureWatcher;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
|
||||
}; // class ViewshedGeoProcessing
|
||||
|
||||
Reference in new issue
Block a user