-
Notifications
You must be signed in to change notification settings - Fork 74
v0.2.50..v0.2.51 changeset Relation.cpp
Garret Voltz edited this page Jan 15, 2020
·
1 revision
diff --git a/hoot-core/src/main/cpp/hoot/core/elements/Relation.cpp b/hoot-core/src/main/cpp/hoot/core/elements/Relation.cpp
index 8035634..87e3cb1 100644
--- a/hoot-core/src/main/cpp/hoot/core/elements/Relation.cpp
+++ b/hoot-core/src/main/cpp/hoot/core/elements/Relation.cpp
@@ -58,6 +58,7 @@ int Relation::logWarnCount = 0;
class AddToVisitedRelationsList
{
public:
+
AddToVisitedRelationsList(QList<long>& relationIds, long thisId) :
_relationIds(relationIds),
_thisId(thisId)
@@ -73,6 +74,7 @@ public:
}
private:
+
QList<long>& _relationIds;
long _thisId;
};
@@ -151,12 +153,11 @@ Envelope* Relation::getEnvelope(const std::shared_ptr<const ElementProvider>& ep
return new Envelope(getEnvelopeInternal(ep));
}
-Envelope Relation::getEnvelopeInternal(const std::shared_ptr<const ElementProvider>& ep) const
+const Envelope& Relation::getEnvelopeInternal(const std::shared_ptr<const ElementProvider>& ep) const
{
LOG_VART(ep.get());
- Envelope result;
- result.init();
+ _cachedEnvelope.init();
const vector<RelationData::Entry>& members = getMembers();
@@ -169,8 +170,8 @@ Envelope Relation::getEnvelopeInternal(const std::shared_ptr<const ElementProvid
if (ep->containsElement(m.getElementId()) == false)
{
LOG_TRACE(m.getElementId() << " missing. Returning empty envelope...");
- result.setToNull();
- return result;
+ _cachedEnvelope.setToNull();
+ return _cachedEnvelope;
}
const std::shared_ptr<const Element> e = ep->getElement(m.getElementId());
@@ -180,15 +181,15 @@ Envelope Relation::getEnvelopeInternal(const std::shared_ptr<const ElementProvid
if (childEnvelope->isNull())
{
LOG_TRACE("Child envelope for " << m.getElementId() << " null. Returning empty envelope...");
- result.setToNull();
- return result;
+ _cachedEnvelope.setToNull();
+ return _cachedEnvelope;
}
- result.expandToInclude(childEnvelope.get());
+ _cachedEnvelope.expandToInclude(childEnvelope.get());
}
- LOG_VART(result);
- return result;
+ LOG_VART(_cachedEnvelope);
+ return _cachedEnvelope;
}
void Relation::_makeWritable()
@@ -222,7 +223,7 @@ void Relation::removeElement(ElementId eid)
}
void Relation::replaceElement(const std::shared_ptr<const Element>& from,
- const std::shared_ptr<const Element> &to)
+ const std::shared_ptr<const Element>& to)
{
_preGeometryChange();
_makeWritable();
@@ -230,6 +231,14 @@ void Relation::replaceElement(const std::shared_ptr<const Element>& from,
_postGeometryChange();
}
+void Relation::replaceElement(const ElementId& from, const ElementId& to)
+{
+ _preGeometryChange();
+ _makeWritable();
+ _relationData->replaceElement(from, to);
+ _postGeometryChange();
+}
+
void Relation::replaceElement(const ConstElementPtr& from, const QList<ElementPtr>& to)
{
_preGeometryChange();