-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
119 lines (90 loc) · 3.51 KB
/
main.cpp
File metadata and controls
119 lines (90 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// Copyright 2022 ESRI
//
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
//
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
//
// See the Sample code usage restrictions document for further information.
//
// Qt headers
#include <QApplication>
#include <QMessageBox>
#include <QDir>
#include <QXmlStreamReader>
#include <QFile>
#include <QDebug>
#include <QObject>
#include "ArcGISRuntimeEnvironment.h"
#include "Cockpit_arcgis.h"
#include "zmqreciever.h"
#include "coordinategrabber.h"
using namespace Esri::ArcGISRuntime;
int main(int argc, char *argv[])
{
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
qRegisterMetaType<QVector<double> >("QVector"); //https://forum.qt.io/topic/82220/qobject-connect-cannot-queue-arguments-message/2
QApplication application(argc, argv);
// Use of Esri location services, including basemaps and geocoding, requires
// either an ArcGIS identity or an API key. For more information see
// https://links.esri.com/arcgis-runtime-security-auth.
// 1. ArcGIS identity: An ArcGIS named user account that is a member of an
// organization in ArcGIS Online or ArcGIS Enterprise.
// 2. API key: A permanent key that gives your application access to Esri
// location services. Create a new API key or access existing API keys from
// your ArcGIS for Developers dashboard (https://links.esri.com/arcgis-api-keys).
// read API Key from xml file
QString apiKey;
QFile xmlFile(":/guiParamFile.xml");
if(!xmlFile.open(QFile::ReadOnly | QFile::Text)){
qDebug() << "Cannot read file" << xmlFile.errorString();
exit(0);
}
QXmlStreamReader xmlReader(&xmlFile);
if (xmlReader.readNextStartElement()){
if (xmlReader.name() =="dataParameters") {
while(xmlReader.readNextStartElement()) {
if (xmlReader.name() == "apiKey"){
apiKey = xmlReader.readElementText();
break;
}
else {
xmlReader.skipCurrentElement();
}
}
}
}
xmlFile.close();
if (apiKey.isEmpty())
{
qWarning() << "Use of Esri location services, including basemaps, requires" <<
"you to authenticate with an ArcGIS identity or set the API Key property.";
}
else
{
ArcGISRuntimeEnvironment::setApiKey(apiKey);
}
// Production deployment of applications built with ArcGIS Runtime requires you to
// license ArcGIS Runtime functionality. For more information see
// https://links.esri.com/arcgis-runtime-license-and-deploy.
// ArcGISRuntimeEnvironment::setLicense("Place license string in here");
// use this code to check for initialization errors
// QObject::connect(ArcGISRuntimeEnvironment::instance(), &ArcGISRuntimeEnvironment::errorOccurred, [](const Error& error){
// QMessageBox msgBox;
// msgBox.setText(error.message);
// msgBox.exec();
// });
// if (ArcGISRuntimeEnvironment::initialize() == false)
// {ac
// application.quit();
// return 1;
// }
cockpitArcgis applicationWindow;
applicationWindow.setMinimumWidth(800);
applicationWindow.setMinimumHeight(600);
applicationWindow.show();
CoordinateGrabber c;
return application.exec();
}