diff --git a/native-apps/urban-heat-analyzer/UrbanHeatAnalyzer/UrbanHeatAnalyzer.cpp b/native-apps/urban-heat-analyzer/UrbanHeatAnalyzer/UrbanHeatAnalyzer.cpp index 3f6a72a..e778e56 100644 --- a/native-apps/urban-heat-analyzer/UrbanHeatAnalyzer/UrbanHeatAnalyzer.cpp +++ b/native-apps/urban-heat-analyzer/UrbanHeatAnalyzer/UrbanHeatAnalyzer.cpp @@ -22,9 +22,11 @@ #include "UrbanHeatAnalyzer.h" +#include "ArcGISSceneLayer.h" #include "ArcGISTiledElevationSource.h" #include "ArcGISVectorTiledLayer.h" #include "AttributeListModel.h" +#include "Camera.h" #include "CoreTypes.h" #include "ElevationSourceListModel.h" #include "Envelope.h" @@ -36,10 +38,12 @@ #include "LayerListModel.h" #include "MapTypes.h" #include "OrderBy.h" +#include "Point.h" #include "QueryParameters.h" #include "Scene.h" #include "SceneQuickView.h" #include "ServiceFeatureTable.h" +#include "SpatialReference.h" #include "Surface.h" #include "VectorTileCache.h" #include "Viewpoint.h" @@ -55,13 +59,26 @@ UrbanHeatAnalyzer::UrbanHeatAnalyzer(QObject *parent /* = nullptr */) : QObject(parent) , m_scene(new Scene(BasemapStyle::OsmStandard, this)) { + // create a new scene layer from OSM Buildings rest service + ArcGISSceneLayer *osmSceneLayer = new ArcGISSceneLayer( + QUrl("https://basemaps3d.arcgis.com/arcgis/rest/services/" + "OpenStreetMap3D_Buildings_v1/SceneServer"), + this); + osmSceneLayer->setOpacity(0.75f); + + // add the scene layer to the scene + m_scene->operationalLayers()->append(osmSceneLayer); + // create a new elevation source from Terrain3D rest service - ArcGISTiledElevationSource *elevationSource - = new ArcGISTiledElevationSource(QUrl("https://elevation3d.arcgis.com/arcgis/rest/services/" - "WorldElevation3D/Terrain3D/ImageServer"), - this); + ArcGISTiledElevationSource *elevationSource = new ArcGISTiledElevationSource( + QUrl("https://elevation3d.arcgis.com/arcgis/rest/services/" + "WorldElevation3D/Terrain3D/ImageServer"), + this); + + // add the elevation source to the scene to display elevation + m_scene->baseSurface()->elevationSources()->append(elevationSource); - // add vector tile cache + // create a new vector tile cache from the exported vector tile package VectorTileCache *tileCache = new VectorTileCache( "/data/Germany/Bonn/heat_risk_index_bonn.vtpk", this); @@ -70,14 +87,52 @@ UrbanHeatAnalyzer::UrbanHeatAnalyzer(QObject *parent /* = nullptr */) ArcGISVectorTiledLayer *tiledLayer = new ArcGISVectorTiledLayer( tileCache, this); + tiledLayer->setOpacity(0.33f); + connect(tiledLayer, &ArcGISVectorTiledLayer::doneLoading, this, [tiledLayer, this]() { - Envelope layerExtent = tiledLayer->fullExtent(); - Viewpoint viewpoint = Viewpoint(layerExtent); - m_sceneView->setViewpointAsync(viewpoint, 2.5); + //Envelope layerExtent = tiledLayer->fullExtent(); + //Viewpoint viewpoint = Viewpoint(layerExtent); + //m_sceneView->setViewpointAsync(viewpoint, 2.5); + //m_sceneView->currentViewpointCamera(); + //m_sceneView->setViewpointCameraAsync() + + // Set the viewpoint on a specific target + Point targetLocation(7.11661 , 50.718 , 343.663, SpatialReference(4326)); + Camera targetCamera(targetLocation, 93.2121 , 60.7764 , -5.68434e-14); + Viewpoint targetViewpoint(targetLocation, targetCamera); + if (m_sceneView) + { + m_sceneView->setViewpointAsync(targetViewpoint, 10); + } + + //loadHeatRiskFeatures(); }); m_scene->operationalLayers()->append(tiledLayer); +} + +UrbanHeatAnalyzer::~UrbanHeatAnalyzer() {} + +SceneQuickView *UrbanHeatAnalyzer::sceneView() const +{ + return m_sceneView; +} + +// Set the view (created in QML) +void UrbanHeatAnalyzer::setSceneView(SceneQuickView *sceneView) +{ + if (!sceneView || sceneView == m_sceneView) { + return; + } + + m_sceneView = sceneView; + m_sceneView->setArcGISScene(m_scene); + emit sceneViewChanged(); +} + +void UrbanHeatAnalyzer::loadHeatRiskFeatures() +{ // add the features Geodatabase *gdb = new Geodatabase( "/data/Germany/Bonn/HRI Bonn.geodatabase", @@ -103,8 +158,8 @@ UrbanHeatAnalyzer::UrbanHeatAnalyzer(QObject *parent /* = nullptr */) auto queryResult = std::unique_ptr(rawQueryResult); if (queryResult && !queryResult->iterator().hasNext()) { - // No results or invalid pointer - return; + // No results or invalid pointer + return; } QMap> analysisGroups; @@ -143,27 +198,12 @@ UrbanHeatAnalyzer::UrbanHeatAnalyzer(QObject *parent /* = nullptr */) featureTable->load(); }); gdb->load(); - - // add the elevation source to the scene to display elevation - m_scene->baseSurface()->elevationSources()->append(elevationSource); -} - -UrbanHeatAnalyzer::~UrbanHeatAnalyzer() {} - -SceneQuickView *UrbanHeatAnalyzer::sceneView() const -{ - return m_sceneView; } -// Set the view (created in QML) -void UrbanHeatAnalyzer::setSceneView(SceneQuickView *sceneView) +void UrbanHeatAnalyzer::printCamera() { - if (!sceneView || sceneView == m_sceneView) { - return; - } - - m_sceneView = sceneView; - m_sceneView->setArcGISScene(m_scene); - - emit sceneViewChanged(); + auto camera = m_sceneView->currentViewpointCamera(); + auto location = camera.location(); + qDebug() << location.x() << "," << location.y() << "," << location.z(); + qDebug() << camera.heading() << "," << camera.pitch() << "," << camera.roll(); } diff --git a/native-apps/urban-heat-analyzer/UrbanHeatAnalyzer/UrbanHeatAnalyzer.h b/native-apps/urban-heat-analyzer/UrbanHeatAnalyzer/UrbanHeatAnalyzer.h index 9235029..714ae1c 100644 --- a/native-apps/urban-heat-analyzer/UrbanHeatAnalyzer/UrbanHeatAnalyzer.h +++ b/native-apps/urban-heat-analyzer/UrbanHeatAnalyzer/UrbanHeatAnalyzer.h @@ -9,6 +9,16 @@ // // See the Sample code usage restrictions document for further information. // +// This "Urban Heat Analyzer" sample app is licensed as +// SPDX-License-Identifier: GPL-3.0-or-later +// +// Additional permission under GNU GPL version 3 section 4 and 5 +// If you modify this Program, or any covered work, by linking or combining +// it with ArcGIS Runtime for Qt (or a modified version of that library), +// containing parts covered by the terms of ArcGIS Runtime for Qt, +// the licensors of this Program grant you additional permission to convey the resulting work. +// See for further information. +// #ifndef URBANHEATANALYZER_H #define URBANHEATANALYZER_H @@ -33,10 +43,14 @@ class UrbanHeatAnalyzer : public QObject explicit UrbanHeatAnalyzer(QObject *parent = nullptr); ~UrbanHeatAnalyzer() override; + Q_INVOKABLE void printCamera(); + signals: void sceneViewChanged(); private: + void loadHeatRiskFeatures(); + Esri::ArcGISRuntime::SceneQuickView *sceneView() const; void setSceneView(Esri::ArcGISRuntime::SceneQuickView *sceneView); diff --git a/native-apps/urban-heat-analyzer/UrbanHeatAnalyzer/qml/UrbanHeatAnalyzerForm.qml b/native-apps/urban-heat-analyzer/UrbanHeatAnalyzer/qml/UrbanHeatAnalyzerForm.qml index 49d988b..81f02ad 100644 --- a/native-apps/urban-heat-analyzer/UrbanHeatAnalyzer/qml/UrbanHeatAnalyzerForm.qml +++ b/native-apps/urban-heat-analyzer/UrbanHeatAnalyzer/qml/UrbanHeatAnalyzerForm.qml @@ -9,6 +9,16 @@ // // See the Sample code usage restrictions document for further information. // +// This "Urban Heat Analyzer" sample app is licensed as +// SPDX-License-Identifier: GPL-3.0-or-later +// +// Additional permission under GNU GPL version 3 section 4 and 5 +// If you modify this Program, or any covered work, by linking or combining +// it with ArcGIS Runtime for Qt (or a modified version of that library), +// containing parts covered by the terms of ArcGIS Runtime for Qt, +// the licensors of this Program grant you additional permission to convey the resulting work. +// See for further information. +// import QtQuick import QtQuick.Controls @@ -16,6 +26,10 @@ import Esri.UrbanHeatAnalyzer Item { + function printCamera() { + model.printCamera(); + } + // Create SceneQuickView here, and create its Scene etc. in C++ code SceneView { id: view diff --git a/native-apps/urban-heat-analyzer/UrbanHeatAnalyzer/qml/main.qml b/native-apps/urban-heat-analyzer/UrbanHeatAnalyzer/qml/main.qml index f6b1f45..3a07369 100644 --- a/native-apps/urban-heat-analyzer/UrbanHeatAnalyzer/qml/main.qml +++ b/native-apps/urban-heat-analyzer/UrbanHeatAnalyzer/qml/main.qml @@ -9,8 +9,21 @@ // // See the Sample code usage restrictions document for further information. // +// This "Urban Heat Analyzer" sample app is licensed as +// SPDX-License-Identifier: GPL-3.0-or-later +// +// Additional permission under GNU GPL version 3 section 4 and 5 +// If you modify this Program, or any covered work, by linking or combining +// it with ArcGIS Runtime for Qt (or a modified version of that library), +// containing parts covered by the terms of ArcGIS Runtime for Qt, +// the licensors of this Program grant you additional permission to convey the resulting work. +// See for further information. +// import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Layouts + import Esri.UrbanHeatAnalyzer ApplicationWindow { @@ -18,7 +31,37 @@ ApplicationWindow { width: 800 height: 600 + Material.theme: Material.Dark + Material.accent: "#C9F2FF" + Material.background: "#0289C3" + Material.foreground: "#FFFFFF" + Material.primary: "#035799" + + font.pixelSize: 14 + + footer: ToolBar { + + RowLayout { + anchors.fill: parent + + Label { + id: messageLabel + horizontalAlignment: Qt.AlignLeft + Layout.leftMargin: 15 + Layout.fillWidth: true + text: qsTr("Analyzing urban heat risks...") + } + + Button { + onClicked: { + mapForm.printCamera(); + } + } + } + } + UrbanHeatAnalyzerForm { + id: mapForm anchors.fill: parent } }