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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245 | /* ============================================================
*
* This file is a part of digiKam project
* https://www.digikam.org
*
* Date : 2023-05-15
* Description : geolocation engine based on Marble.
* (c) 2007-2022 Marble Team
* https://invent.kde.org/education/marble/-/raw/master/data/credits_authors.html
*
* SPDX-FileCopyrightText: 2023-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* ============================================================ */
#pragma once
#include "GeoDataFeature.h"
// Qt includes
#include <QString>
// Local includes
#include "GeoDataExtendedData.h"
#include "GeoDataAbstractView.h"
#include "GeoDataRegion.h"
#include "GeoDataTimeStamp.h"
#include "GeoDataTimeSpan.h"
#include "GeoDataTypes.h"
#include "GeoDataStyle.h"
#include "GeoDataSnippet.h"
#include "GeoDataLookAt.h"
#include "GeoDataCamera.h"
namespace Marble
{
class Q_DECL_HIDDEN GeoDataFeatureExtendedData
{
public:
GeoDataSnippet m_snippet; // Snippet of the feature.
QString m_description; // A longer textual description
bool m_descriptionCDATA; // True if description should be considered CDATA
QString m_address; // The address. Optional
QString m_phoneNumber; // Phone Optional
GeoDataAbstractView* m_abstractView = nullptr; // AbstractView Optional
GeoDataTimeSpan m_timeSpan;
GeoDataTimeStamp m_timeStamp;
GeoDataRegion m_region;
public:
GeoDataFeatureExtendedData()
: m_snippet(),
m_description(),
m_descriptionCDATA(false),
m_address(),
m_phoneNumber(),
m_abstractView(nullptr),
m_timeSpan(),
m_timeStamp(),
m_region()
{
// nothing to do
}
GeoDataFeatureExtendedData(const GeoDataFeatureExtendedData& other)
: m_snippet(other.m_snippet),
m_description(other.m_description),
m_descriptionCDATA(other.m_descriptionCDATA),
m_address(other.m_address),
m_phoneNumber(other.m_phoneNumber),
m_abstractView(other.m_abstractView),
m_timeSpan(other.m_timeSpan),
m_timeStamp(other.m_timeStamp),
m_region(other.m_region)
{
// nothing to do
}
GeoDataFeatureExtendedData& operator=(const GeoDataFeatureExtendedData& other)
{
m_snippet = other.m_snippet;
m_description = other.m_description;
m_descriptionCDATA = other.m_descriptionCDATA;
m_address = other.m_address;
m_phoneNumber = other.m_phoneNumber;
m_abstractView = other.m_abstractView;
m_timeSpan = other.m_timeSpan;
m_timeStamp = other.m_timeStamp;
m_region = other.m_region;
return *this;
}
bool operator==(const GeoDataFeatureExtendedData& other) const
{
if (m_snippet != other.m_snippet ||
m_description != other.m_description ||
m_descriptionCDATA != other.m_descriptionCDATA ||
m_address != other.m_address ||
m_phoneNumber != other.m_phoneNumber ||
m_timeSpan != other.m_timeSpan ||
m_timeStamp != other.m_timeStamp ||
m_region != other.m_region)
{
return false;
}
if ((!m_abstractView && other.m_abstractView) ||
(m_abstractView && !other.m_abstractView))
{
return false;
}
if (m_abstractView && other.m_abstractView)
{
if (*m_abstractView != *other.m_abstractView)
{
return false;
}
}
return true;
}
bool operator!=(const GeoDataFeatureExtendedData& other) const
{
return !(*this == other);
}
};
class Q_DECL_HIDDEN GeoDataFeaturePrivate
{
public:
GeoDataFeaturePrivate()
: m_name(),
m_styleUrl(),
m_popularity(0),
m_zoomLevel(1),
m_visible(true),
m_role(QLatin1String(" ")),
m_style(nullptr),
m_styleMap(nullptr),
m_extendedData(),
m_featureExtendedData(nullptr)
{
}
GeoDataFeaturePrivate(const GeoDataFeaturePrivate& other)
: m_name(other.m_name),
m_styleUrl(other.m_styleUrl),
m_popularity(other.m_popularity),
m_zoomLevel(other.m_zoomLevel),
m_visible(other.m_visible),
m_role(other.m_role),
m_style(other.m_style), // FIXME: both style and stylemap need to be reworked internally!!!!
m_styleMap(other.m_styleMap),
m_extendedData(other.m_extendedData),
m_featureExtendedData(nullptr)
{
if (other.m_featureExtendedData)
{
m_featureExtendedData = new GeoDataFeatureExtendedData(*other.m_featureExtendedData);
}
}
GeoDataFeaturePrivate& operator=(const GeoDataFeaturePrivate& other)<--- 'operator=' should check for assignment to self to avoid problems with dynamic memory. [+]'operator=' should check for assignment to self to ensure that each block of dynamically allocated memory is owned and managed by only one instance of the class.
{
m_name = other.m_name;
m_styleUrl = other.m_styleUrl;
m_popularity = other.m_popularity;
m_zoomLevel = other.m_zoomLevel;
m_visible = other.m_visible;
m_role = other.m_role;
m_style = other.m_style;
m_styleMap = other.m_styleMap;
m_extendedData = other.m_extendedData;
delete m_featureExtendedData;
m_featureExtendedData = nullptr;
if (other.m_featureExtendedData)
{
m_featureExtendedData = new GeoDataFeatureExtendedData(*other.m_featureExtendedData);
}
return *this;
}
virtual EnumFeatureId featureId() const
{
return InvalidFeatureId;
}
virtual ~GeoDataFeaturePrivate()
{
delete m_featureExtendedData;
}
GeoDataFeatureExtendedData& featureExtendedData()
{
if (!m_featureExtendedData)
{
m_featureExtendedData = new GeoDataFeatureExtendedData;
}
return *m_featureExtendedData;
}
const GeoDataFeatureExtendedData& featureExtendedData() const
{
if (!m_featureExtendedData)
{
m_featureExtendedData = new GeoDataFeatureExtendedData;
}
return *m_featureExtendedData;
}
public:
QString m_name; // Name of the feature. Is shown on screen
QString m_styleUrl; // styleUrl Url#tag to a document wide style
qint64 m_popularity; // Population/Area/Altitude depending on placemark(!)
int m_zoomLevel; // Zoom Level of the feature
bool m_visible; // True if this feature should be shown.
QString m_role;
GeoDataStyle::Ptr m_style;
const GeoDataStyleMap* m_styleMap = nullptr;
GeoDataExtendedData m_extendedData;
mutable GeoDataFeatureExtendedData* m_featureExtendedData = nullptr;
};
} // namespace Marble
|