Initial commit

This commit is contained in:
torsten committed 2026-08-13 18:33:10 +02:00
commit b7d90b9afe
16245 files changed
+3396666

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
#
# $Id$
# $HeadURL$
# $Author$
#
# Evaluation application for 3D viewshed
FIND_PACKAGE(ArcGIS REQUIRED)
INCLUDE_DIRECTORIES(${ARCGIS_INCLUDE_DIR}/arcgis)
SET(EXE_SRCS
main.cpp
ViewshedLocation.cpp
)
SET(EXE_HDRS
ViewshedLocation.h
)
SOURCE_GROUP(EvalViewshed3DApp FILES ${EXE_SRCS} ${EXE_HDRS})
NGL_ADD_EXECUTABLE(WS NO_TRANSLATION EvalViewshed3DApp ${EXE_SRCS} ${EXE_HDRS})
NGL_TARGET_LINK_LIBRARIES(
EvalViewshed3DApp
ArcGIS::ArcGIS
Qt5::Core
Qt5::Gui
Qt5::Widgets
Qt5::Network
)
IF(MSVC)
# Configure the template file
SET(VS_USER_FILE EvalViewshed3DApp.vcxproj.user)
configure_file( ../../SituationMap.vcxproj.user.in ${CMAKE_CURRENT_BINARY_DIR}/${VS_USER_FILE} @ONLY)
ENDIF(MSVC)
NGL_INSTALL_TARGET(EvalViewshed3DApp)
@@ -0,0 +1,58 @@
#-------------------------------------------------
# Copyright 2015 Esri.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#-------------------------------------------------
mac {
cache()
}
CONFIG += c++11 esri_runtime_qt100_0_0 debug
QT += core gui opengl xml network positioning sensors
win32:CONFIG += \
embed_manifest_exe
TARGET = LocationViewshed
TEMPLATE = app
SOURCES += \
main.cpp \
ViewshedLocation.cpp
HEADERS += \
ViewshedLocation.h
win32 {
INCLUDEPATH += "C:/Program Files (x86)/ArcGIS SDKs/Qt100.0/sdk/include"
debug:LIBPATH += "C:/Program Files (x86)/ArcGIS SDKs/Qt100.0/sdk/windows/x64/lib/Debug"
release:LIBPATH += "C:/Program Files (x86)/ArcGIS SDKs/Qt100.0/sdk/windows/x64/lib/Release"
debug:LIBS += -lEsriCommonQtd
release:LIBS += -lEsriCommonQt
debug:LIBS += -lEsriRuntimeQtd
release:LIBS += -lEsriRuntimeQt
}
linux {
INCLUDEPATH += /usr/include/arcgis
LIBS += -lEsriCommonQt
LIBS += -lEsriRuntimeQt
LIBS += -lc++
}
macx {
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.11
}
@@ -0,0 +1,274 @@
/**
* @RDE_HEADER@
* Declaration/Definition
* $Id$
* $HeadURL$
* $Author$
*/
// [WriteFile Name=ViewshedLocation, Category=Analysis]
// [Legal]
// Copyright 2017 Esri.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// [Legal]
#include "ViewshedLocation.h"
#include "ArcGISTiledElevationSource.h"
#include "Scene.h"
#include "SceneGraphicsView.h"
#include "LocationViewshed.h"
#include "Camera.h"
#include "Point.h"
#include "AnalysisOverlay.h"
#include "QColor"
using namespace Esri::ArcGISRuntime;
ViewshedLocation::ViewshedLocation(QObject* parent /* = nullptr */):
QObject(parent)
{
}
void ViewshedLocation::init(Esri::ArcGISRuntime::SceneGraphicsView* sceneView)
{
m_sceneView = sceneView;
// Register classes for QML
// qmlRegisterType<SceneQuickView>("Esri.Samples", 1, 0, "SceneView");
// qmlRegisterType<ViewshedLocation>("Esri.Samples", 1, 0, "ViewshedLocationSample");
Surface* surface = new Surface(this);
surface->elevationSources()->append(
new ArcGISTiledElevationSource(
QUrl(QStringLiteral("http://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")),
this));
m_sceneView->arcGISScene()->setBaseSurface(surface);
// set initial viewpoint
setInitialViewpoint();
// connect signals
connectSignals();
}
void ViewshedLocation::setInitialViewpoint()
{
// Set a viewpoint
double x = 6.86088;
double y = 45.3604;
double z = 3582.55;
Point point(x, y, z, SpatialReference(4326));
double heading = 345;
double pitch = 70;
double roll = 0;
Camera camera(point, heading, pitch, roll);
m_sceneView->setViewpointCamera(camera);
}
void ViewshedLocation::connectSignals()
{
// on mouse click perform the location viewshed
connect(m_sceneView, &SceneGraphicsView::mouseClicked, this, [this](QMouseEvent& event)
{
if (!m_locationViewshed[0])
createViewshed(event.x(), event.y());
else
{
for (int i = 0; i < 3; ++i)
{
const Point pt = m_sceneView->screenToBaseSurface(event.x(), event.y());
m_locationViewshed[i]->setLocation(pt);
}
}
});
connect(m_sceneView, &SceneGraphicsView::mousePressedAndHeld, this, [this](QMouseEvent& event)
{
if (!m_locationViewshed[0])
createViewshed(event.x(), event.y());
m_calculating = true;
});
connect(m_sceneView, &SceneGraphicsView::mouseMoved, this, [this](QMouseEvent& event)
{
if (m_calculating)
{
for (int i = 0; i < 3; ++i)
{
const Point pt = m_sceneView->screenToBaseSurface(event.x(), event.y());
m_locationViewshed[i]->setLocation(pt);
}
}
});
connect(m_sceneView, &SceneGraphicsView::mouseReleased, this, [this](QMouseEvent)
{
m_calculating = false;
});
}
void ViewshedLocation::createViewshed(double x, double y)
{
m_analysisOverlay = new AnalysisOverlay(this);
m_sceneView->analysisOverlays()->append(m_analysisOverlay);
const Point pt = m_sceneView->screenToBaseSurface(x, y);
qCritical() << " pt=";
qCritical() << " pt=" << pt.x();
qCritical() << " pt=" << pt.y();
qCritical() << " pt=" << pt.z();
for (int i = 0; i < 3; ++i)
{
double heading = i * 120.0;
m_locationViewshed[i] = new LocationViewshed(pt
, heading
, 90.0 // pitch
, 120.0 // horizontalAngle
, 90.0 // verticalAngle
, 10.0 // minDistance
, 20000
, this);
m_locationViewshed[i]->setVisible(m_viewshedVisible);
// Add the Viewshed to the Analysis Overlay
m_analysisOverlay->analyses()->append(m_locationViewshed[i]);
m_locationViewshed[i]->setFrustumOutlineVisible(true);
// QColor frustumColor(0, 0, 0, 255);
// m_locationViewshed->setFrustumOutlineColor(frustumColor);
}
return;
}
// Getters/Setters for each Q_PROPERTY
bool ViewshedLocation::isViewshedVisible() const
{
return m_viewshedVisible;
}
void ViewshedLocation::setViewshedVisible(bool viewshedVisible)
{
for (int i = 0; i < 3; ++i)
{
if (m_locationViewshed[i])
{
if (m_locationViewshed[i]->isVisible() == viewshedVisible)
{
continue;
}
m_locationViewshed[i]->setVisible(viewshedVisible);
}
}
if (m_viewshedVisible != viewshedVisible)
{
m_viewshedVisible = viewshedVisible;
emit viewshedVisibleChanged();
}
}
bool ViewshedLocation::isFrustumOutlineVisible() const
{
return m_locationViewshed[0] ? m_locationViewshed[0]->isFrustumOutlineVisible() : m_frustumVisible;
}
void ViewshedLocation::setFrustumOutlineVisible(bool frustumVisible)
{
for (int i = 0; i < 3; ++i)
{
if (m_locationViewshed[i])
{
if (m_locationViewshed[i]->isFrustumOutlineVisible() == frustumVisible)
{
continue;
}
m_frustumVisible = frustumVisible;
m_locationViewshed[i]->setFrustumOutlineVisible(frustumVisible);
}
}
if (m_frustumVisible != frustumVisible)
{
m_frustumVisible = frustumVisible;
emit frustumVisibleChanged();
}
}
double ViewshedLocation::minDistance() const
{
return m_locationViewshed[0] ? m_locationViewshed[0]->minDistance() : m_minDistance;
}
void ViewshedLocation::setMinDistance(double minDistance)
{
for (int i = 0; i < 3; ++i)
{
if (m_locationViewshed[i])
{
if (m_locationViewshed[i]->minDistance() == minDistance)
{
continue;
}
m_locationViewshed[i]->setMinDistance(minDistance);
}
}
if (m_minDistance != minDistance)
{
m_minDistance = minDistance;
emit minDistanceChanged();
}
}
double ViewshedLocation::maxDistance() const
{
return m_locationViewshed[0] ? m_locationViewshed[0]->maxDistance() : m_maxDistance;
}
void ViewshedLocation::setMaxDistance(double maxDistance)
{
for (int i = 0; i < 3; ++i)
{
if (m_locationViewshed[i])
{
if (m_locationViewshed[i]->maxDistance() == maxDistance)
{
continue;
}
m_locationViewshed[i]->setMaxDistance(maxDistance);
}
}
if (m_maxDistance != maxDistance)
{
m_maxDistance = maxDistance;
emit maxDistanceChanged();
}
}
@@ -0,0 +1,99 @@
/**
* @RDE_HEADER@
* Declaration/Definition
* $Id$
* $HeadURL$
* $Author$
*/
// [WriteFile Name=ViewshedLocation, Category=Analysis]
// [Legal]
// Copyright 2017 Esri.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// [Legal]
#ifndef VIEWSHEDLOCATION_H
#define VIEWSHEDLOCATION_H
#include <QObject>
#include <QColor>
namespace Esri
{
namespace ArcGISRuntime
{
class SceneGraphicsView;
class LocationViewshed;
class AnalysisOverlay;
}
}
class ViewshedLocation : public QObject
{
Q_OBJECT
public:
explicit ViewshedLocation(QObject* parent = nullptr);
~ViewshedLocation() = default;
// void componentComplete() Q_DECL_OVERRIDE;
void init(Esri::ArcGISRuntime::SceneGraphicsView* sceneView);
Q_PROPERTY(bool viewshedVisible READ isViewshedVisible WRITE setViewshedVisible NOTIFY viewshedVisibleChanged)
Q_PROPERTY(bool frustumVisible READ isFrustumOutlineVisible WRITE setFrustumOutlineVisible NOTIFY frustumVisibleChanged)
Q_PROPERTY(double minDistance READ minDistance WRITE setMinDistance NOTIFY minDistanceChanged)
Q_PROPERTY(double maxDistance READ maxDistance WRITE setMaxDistance NOTIFY maxDistanceChanged)
bool isViewshedVisible() const;
void setViewshedVisible(bool viewshedVisible);
bool isFrustumOutlineVisible() const;
void setFrustumOutlineVisible(bool frustumVisible);
double minDistance() const;
void setMinDistance(double minDistance);
double maxDistance() const;
void setMaxDistance(double maxDistance);
signals:
void viewshedVisibleChanged();
void frustumVisibleChanged();
void minDistanceChanged();
void maxDistanceChanged();
private:
void connectSignals();
void setInitialViewpoint();
void createViewshed(double x, double y);
Esri::ArcGISRuntime::SceneGraphicsView *m_sceneView = nullptr;
Esri::ArcGISRuntime::LocationViewshed *m_locationViewshed[3] = { nullptr, nullptr, nullptr };
Esri::ArcGISRuntime::AnalysisOverlay *m_analysisOverlay = nullptr;
bool m_viewshedVisible = true;
bool m_frustumVisible = false;
double m_minDistance = 50;
double m_maxDistance = 1000;
double m_horizontalAngle = 45;
double m_veriticalAngle = 90;
double m_heading = 0;
double m_pitch = 90;
bool m_calculating = false;
};
#endif // VIEWSHEDLOCATION_H
+245
View File
@@ -0,0 +1,245 @@
/*
**
** @RDE_HEADER@
** Showing artefacts when drawing 3D map.
** $Id$
** $HeadURL$
** $Author$
**
** -----------------------------------------------------------------------------------------------
**
** Hardware-Environment: Intel-PC
** Software-Environment: Windows 7, Linux, Qt 5.9. ArcGISRuntimeQt 100.1
**
** Language ........: C++ 11
**
** -----------------------------------------------------------------------------------------------
**
** Author ...........: Jörg Turla, SPD G, Tel. 3132
**
** -----------------------------------------------------------------------------------------------
**
** Notes .........:
**
** 08.11.2017, JT : Initial
**
** -----------------------------------------------------------------------------------------------
*/
#include <QTimer>
#include <QtCore/QDir>
#include <QtCore/QUrl>
#include <QtCore/QDebug>
#include <QtGui/QSurface>
#include <QtNetwork/QNetworkProxy>
#include <QtWidgets/QApplication>
#include <QtWidgets/QDesktopWidget>
#include <QtWidgets/QComboBox>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QMessageBox>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QGraphicsScene>
#include <QtWidgets/QGraphicsProxyWidget>
#include <QtWidgets/QMainWindow>
#include <Map.h>
#include <Scene.h>
#include <SceneGraphicsView.h>
#include <GraphicsOverlay.h>
#include <GeoView.h>
#include <Basemap.h>
#include <ArcGISTiledLayer.h>
#include <Layer.h>
#include <GraphicsOverlay.h>
#include "ViewshedLocation.h"
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
class MapWindow : public QWidget
{
Esri::ArcGISRuntime::Basemap * m_basemap;
Esri::ArcGISRuntime::Scene * m_scene;
Esri::ArcGISRuntime::SceneGraphicsView * m_sceneGraphicsView;
Esri::ArcGISRuntime::GeoView * m_mapView;
Esri::ArcGISRuntime::GraphicsOverlay * m_graphicsOverlay;
Qt::MouseButton m_pressedMouseButton;
QPoint m_mouseMoveRefPos;
Esri::ArcGISRuntime::TaskWatcher m_pickingTask;
bool m_pendingRequest;
public:
MapWindow() : QWidget(), m_graphicsOverlay(nullptr), m_pickingTask(), m_pendingRequest(false)
{
m_pressedMouseButton = Qt::MouseButton::NoButton;
m_mouseMoveRefPos = QPoint();
m_basemap = new Esri::ArcGISRuntime::Basemap(this);
m_scene = new Esri::ArcGISRuntime::Scene(m_basemap,this);
connect( m_basemap, &Esri::ArcGISRuntime::Map::errorOccurred , this, &MapWindow::onErrorBasemap );
connect( m_scene , &Esri::ArcGISRuntime::Scene::errorOccurred, this, &MapWindow::onErrorScene );
connect( m_scene , &Esri::ArcGISRuntime::Scene::doneLoading , this, &MapWindow::onDoneLoading );
m_sceneGraphicsView = nullptr;
try
{
m_sceneGraphicsView = new Esri::ArcGISRuntime::SceneGraphicsView(); // no parent,
m_sceneGraphicsView->setObjectName(QLatin1String("EsriSceneView"));
m_sceneGraphicsView->setFrameShape(QFrame::NoFrame); // frameless
}
catch (std::exception &stdEx)
{
const char *what = stdEx.what();
if (what)
qCritical()<< "MapWindow init SceneGraphicsView: std Exception " << " what: '" << what << "'";
else
qCritical() << "MapWindow init SceneGraphicsView: std Exception";
throw; // re-throw
}
catch (...)
{
qCritical() << "MapWindow init SceneGraphicsView: unknown Exception";
throw; // re-throw
}
if (!m_sceneGraphicsView)
return;
m_sceneGraphicsView->setArcGISScene(m_scene);
QHBoxLayout *layout = new QHBoxLayout(this);
layout->addWidget(m_sceneGraphicsView);
initMapLayer(QLatin1String("http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"));
initMapLayer(QLatin1String("http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"));
Esri::ArcGISRuntime::Camera camera(28.4, 83.9, 10010.0, 10.0, 80.0, 300.0);
m_sceneGraphicsView->setViewpointCameraAndWait(camera);// set the viewpoint
/*
QPushButton * aButton = new QPushButton(tr("Click me")); // toplevel widget
QGraphicsProxyWidget *proxy = m_sceneGraphicsView->QGraphicsView::scene()->addWidget(aButton);
proxy->setOpacity(0.99);
connect( aButton, &QPushButton::clicked, this, []() {qCritical() << "A Button has been clicked!";} );
*/
QTimer *timer = new QTimer(this);
timer->setSingleShot(true);
timer->setInterval(5000);
connect(timer, &QTimer::timeout, this, [this]() {
qCritical() << "Create viewshed ...";
ViewshedLocation * vLoc = new ViewshedLocation(this);
vLoc->init(m_sceneGraphicsView);
});
timer->start();
} // MapWindow()
~MapWindow() = default;
void initMapLayer( const QString &mapServiceUrl )
{
Esri::ArcGISRuntime::ArcGISTiledLayer *tiledLayer = new Esri::ArcGISRuntime::ArcGISTiledLayer(QUrl(mapServiceUrl), this);
tiledLayer->setName(mapServiceUrl);
tiledLayer->setObjectName(tiledLayer->name());
m_basemap->baseLayers()->append(tiledLayer);
} // void initMapLayer()
private:
void onDoneLoading(const Esri::ArcGISRuntime::Error &loadError)
{
} // void onDoneLoading(const Esri::ArcGISRuntime::Error &loadError)
void onErrorBasemap(const Esri::ArcGISRuntime::Error &error)
{
qCritical() << " ---EsriError,Basemap --- occured: "
<< " code=" << error.code()
<< " domain=" << (int)error.domain()
<< " extendedErrorType=" << (int)error.extendedErrorType()
<< ", message='" << error.message() << "'";
} // void onErrorBasemap(const Esri::ArcGISRuntime::Error &error)
void onErrorScene(const Esri::ArcGISRuntime::Error &error)
{
qCritical() << " ---EsriError, Scene --- occured: "
<< " code=" << error.code()
<< " domain=" << (int)error.domain()
<< " extendedErrorType=" << (int)error.extendedErrorType()
<< ", message='" << error.message() << "'";
} // void onErrorScene(const Esri::ArcGISRuntime::Error &error)
}; // MapWindow
int main(int argc, char* argv[])
{
QApplication app(argc,argv);
// ESRI :
#ifdef Q_OS_WIN
// Force usage of OpenGL ES through ANGLE on Windows
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
#endif
// : ESRI
#define PROXY
#ifdef PROXY
QNetworkProxy proxy;
proxy.setType(QNetworkProxy::HttpProxy);
proxy.setHostName(QStringLiteral("proxy-rde"));
proxy.setPort(8080);
proxy.setUser(QStringLiteral("norbert.thoden@rheinmetall.com"));
proxy.setPassword(QStringLiteral("RDEWWW11"));
QNetworkProxy::setApplicationProxy(proxy);
#endif
MapWindow * mapWin = new MapWindow();
QDesktopWidget wid;
int width = mapWin->frameGeometry().width();
int height = mapWin->frameGeometry().height();
int screenWidth = wid.screen()->width();
int screenHeight = wid.screen()->height();
mapWin->setGeometry((screenWidth / 2) - (width / 2), (screenHeight / 2) - (height / 2), width, height);
mapWin->show();
app.setQuitOnLastWindowClosed(true);
int retval = app.exec();
delete mapWin;
return retval;
} // main