Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Libraries
KOSMIndoorMap
Commits
4b2b7448
Commit
4b2b7448
authored
Dec 22, 2020
by
Volker Krause
Browse files
Add a helper method to clone an OSM element
parent
7cf6e301
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/osm/element.cpp
View file @
4b2b7448
...
...
@@ -257,3 +257,19 @@ void UniqueElement::setTagValue(TagKey key, const QByteArray &value)
break
;
}
}
UniqueElement
OSM
::
copy_element
(
Element
e
)
{
switch
(
e
.
type
())
{
case
OSM
::
Type
::
Null
:
return
UniqueElement
();
case
OSM
::
Type
::
Node
:
return
UniqueElement
(
new
Node
(
*
e
.
node
()));
case
OSM
::
Type
::
Way
:
return
UniqueElement
(
new
Way
(
*
e
.
way
()));
case
OSM
::
Type
::
Relation
:
return
UniqueElement
(
new
Relation
(
*
e
.
relation
()));
}
Q_UNREACHABLE
();
return
UniqueElement
();
}
src/osm/element.h
View file @
4b2b7448
...
...
@@ -116,6 +116,8 @@ public:
return
*
this
;
}
explicit
inline
operator
bool
()
const
{
return
m_element
.
type
()
!=
OSM
::
Type
::
Null
;
}
constexpr
inline
Element
element
()
const
{
return
m_element
;
}
constexpr
inline
operator
Element
()
const
{
return
m_element
;
}
...
...
@@ -125,6 +127,8 @@ private:
Element
m_element
;
};
/** Creates a copy of @p element. */
KOSM_EXPORT
UniqueElement
copy_element
(
Element
e
);
/** Utility function similar to SQL COALESCE for OSM::Element, ie. this returns the first non-null element passed as argument. */
constexpr
Element
coalesce
(
Element
e
)
{
return
e
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment