7#include "osm/OsmPlacemarkData.h"
10#include "GeoDataExtendedData.h"
12#include <QXmlStreamAttributes>
19 return ::qHash(ident.id, seed) ^ ::qHash((
int)ident.type, seed);
22OsmPlacemarkData::OsmPlacemarkData()
24 , m_href(std::make_shared<OsmPlacemarkDataHashRef>())
29OsmPlacemarkData::~OsmPlacemarkData() =
default;
36qint64 OsmPlacemarkData::id()
const
41qint64 OsmPlacemarkData::oid()
const
43 auto const value = m_tags.value(QStringLiteral(
"mx:oid")).toLong();
44 return value > 0 ? value : m_id;
47QString OsmPlacemarkData::changeset()
const
49 return m_tags.value(QStringLiteral(
"mx:changeset"));
52QString OsmPlacemarkData::version()
const
54 return m_tags.value(QStringLiteral(
"mx:version"));
57QString OsmPlacemarkData::uid()
const
59 return m_tags.value(QStringLiteral(
"mx:uid"));
62QString OsmPlacemarkData::isVisible()
const
64 return m_tags.value(QStringLiteral(
"mx:visible"));
67QString OsmPlacemarkData::user()
const
69 return m_tags.value(QStringLiteral(
"mx:user"));
72QString OsmPlacemarkData::timestamp()
const
74 return m_tags.value(QStringLiteral(
"mx:timestamp"));
77QString OsmPlacemarkData::action()
const
79 return m_tags.value(QStringLiteral(
"mx:action"));
82void OsmPlacemarkData::setId(qint64
id)
87void OsmPlacemarkData::setVersion(
const QString &version)
89 m_tags[QStringLiteral(
"mx:version")] =
version;
92void OsmPlacemarkData::setChangeset(
const QString &changeset)
94 m_tags[QStringLiteral(
"mx:changeset")] = changeset;
97void OsmPlacemarkData::setUid(
const QString &uid)
99 m_tags[QStringLiteral(
"mx:uid")] = uid;
102void OsmPlacemarkData::setVisible(
const QString &visible)
104 m_tags[QStringLiteral(
"mx:visible")] = visible;
107void OsmPlacemarkData::setUser(
const QString &user)
109 m_tags[QStringLiteral(
"mx:user")] = user;
112void OsmPlacemarkData::setTimestamp(
const QString ×tamp)
114 m_tags[QStringLiteral(
"mx:timestamp")] = timestamp;
117void OsmPlacemarkData::setAction(
const QString &action)
119 m_tags[QStringLiteral(
"mx:action")] = action;
124 return m_tags.value(key);
129 m_tags.
insert(key, value);
132void OsmPlacemarkData::removeTag(
const QString &key)
137bool OsmPlacemarkData::containsTag(
const QString &key,
const QString &value)
const
139 auto const iter = m_tags.constFind(key);
140 return iter == m_tags.
constEnd() ? false : iter.value() == value;
143bool OsmPlacemarkData::containsTagKey(
const QString &key)
const
150 return m_tags.constFind(key);
155 return m_tags.begin();
160 return m_tags.constEnd();
165 return m_href->m_nodeReferences[coordinates];
170 return m_href->m_nodeReferences.value(coordinates);
175 m_href->m_nodeReferences.insert(key, value);
180 m_href->m_nodeReferences.remove(key);
183bool OsmPlacemarkData::containsNodeReference(
const GeoDataCoordinates &key)
const
185 return m_href->m_nodeReferences.contains(key);
190 m_href->m_nodeReferences.insert(newKey, m_href->m_nodeReferences.value(oldKey));
191 m_href->m_nodeReferences.remove(oldKey);
196 return m_href->m_memberReferences[key];
201 return m_href->m_memberReferences.value(key);
206 m_href->m_memberReferences.insert(key, value);
209void OsmPlacemarkData::removeMemberReference(
int key)
217 for (; it != end; ++it) {
218 if (it.key() > key) {
219 newHash.
insert(it.key() - 1, it.value());
220 }
else if (it.key() < key) {
221 newHash.
insert(it.key(), it.value());
224 m_href->m_memberReferences = newHash;
227bool OsmPlacemarkData::containsMemberReference(
int key)
const
229 return m_href->m_memberReferences.
contains(key);
234 m_relationReferences.insert({id, type}, role);
237void OsmPlacemarkData::removeRelation(qint64
id)
241 m_relationReferences.remove({id, OsmType::Node});
242 m_relationReferences.remove({id, OsmType::Way});
243 m_relationReferences.remove({id, OsmType::Relation});
246bool OsmPlacemarkData::containsRelation(qint64
id)
const
250 return m_relationReferences.contains({id, OsmType::Node}) || m_relationReferences.contains({id, OsmType::Way})
251 || m_relationReferences.contains({id, OsmType::Relation});
256 return m_relationReferences.begin();
261 return m_relationReferences.constEnd();
264bool OsmPlacemarkData::isNull()
const
269bool OsmPlacemarkData::isEmpty()
const
271 return m_tags.isEmpty() && m_href->m_nodeReferences.isEmpty() && m_href->m_memberReferences.isEmpty() && m_relationReferences.isEmpty();
279 osmData.setVersion(s.toString());
282 osmData.setChangeset(s.toString());
285 osmData.setUser(s.toString());
288 osmData.setUid(s.toString());
291 osmData.setVisible(s.toString());
294 osmData.setTimestamp(s.toString());
297 osmData.setAction(s.toString());
302const char *OsmPlacemarkData::nodeType()
const
304 return "OsmPlacemarkDataType";
309OsmPlacemarkDataHashRef::OsmPlacemarkDataHashRef() =
default;
313 return m_nodeReferences;
318 return m_nodeReferences.begin();
323 return m_nodeReferences.constEnd();
328 return m_memberReferences;
333 return m_memberReferences.begin();
338 return m_memberReferences.constEnd();
A 3d point representation.
Container to host hash-table functions with OsmPlacemarkData as values.
This class is used to encapsulate the osm data fields kept within a placemark's extendedData.
KCOREADDONS_EXPORT unsigned int version()
KTEXTEDITOR_EXPORT size_t qHash(KTextEditor::Cursor cursor, size_t seed=0) noexcept
Binds a QML item to a specific geodetic location in screen coordinates.
OsmType
Type of OSM element.
bool contains(const Key &key) const const
iterator insert(const Key &key, const T &value)
const_iterator constEnd() const const
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
QString & insert(qsizetype position, QChar ch)
QString & remove(QChar ch, Qt::CaseSensitivity cs)
bool isEmpty() const const
QStringView value(QAnyStringView namespaceUri, QAnyStringView name) const const
Identifier for an OSM element.