summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-11-13 16:44:27 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-11-13 16:44:27 (GMT)
commitae56edcc0f27c22cc7c73cb7195335c650571f29 (patch)
tree886e915e72c5d3788c0c51809fd04f320b629680
parentfe4bc8d26ce3d9bfd07a8aa6d73c3d91934678a4 (diff)
Simplify, generalize and improve performance.
- ensures that an id is set - avoid repeated calls to determine osm placemark data instances
-rw-r--r--src/lib/marble/osm/OsmObjectManager.cpp40
1 files changed, 14 insertions, 26 deletions
diff --git a/src/lib/marble/osm/OsmObjectManager.cpp b/src/lib/marble/osm/OsmObjectManager.cpp
index e88a3fb..c765314 100644
--- a/src/lib/marble/osm/OsmObjectManager.cpp
+++ b/src/lib/marble/osm/OsmObjectManager.cpp
@@ -40,10 +40,8 @@ void OsmObjectManager::initializeOsmData( GeoDataPlacemark* placemark )
QVector<GeoDataCoordinates>::ConstIterator const end = lineString->constEnd();
for ( ; it != end; ++it ) {
- if ( !osmData.containsNodeReference( *it ) ) {
- OsmPlacemarkData osmNdData;
- osmNdData.setId( --m_minId );
- osmData.addNodeReference( *it, osmNdData );
+ if (osmData.nodeReference(*it).isNull()) {
+ osmData.nodeReference(*it).setId(--m_minId);
}
}
}
@@ -52,10 +50,8 @@ void OsmObjectManager::initializeOsmData( GeoDataPlacemark* placemark )
if ( placemark->geometry()->nodeType() == GeoDataTypes::GeoDataLinearRingType ) {
const GeoDataLinearRing* lineString = static_cast<GeoDataLinearRing*>( placemark->geometry() );
for (auto it =lineString->constBegin(), end = lineString->constEnd(); it != end; ++it ) {
- if ( !osmData.containsNodeReference( *it ) ) {
- OsmPlacemarkData osmNdData;
- osmNdData.setId( --m_minId );
- osmData.addNodeReference( *it, osmNdData );
+ if (osmData.nodeReference(*it).isNull()) {
+ osmData.nodeReference(*it).setId(--m_minId);
}
}
}
@@ -71,44 +67,36 @@ void OsmObjectManager::initializeOsmData( GeoDataPlacemark* placemark )
}
// Outer boundary
- if ( !osmData.containsMemberReference( index ) ) {
- OsmPlacemarkData outerBoundaryData;
- outerBoundaryData.setId( --m_minId );
- osmData.addMemberReference( index, outerBoundaryData );
+ OsmPlacemarkData &outerBoundaryData = osmData.memberReference( index );
+ if (outerBoundaryData.isNull()) {
+ outerBoundaryData.setId(--m_minId);
}
// Outer boundary nodes
- OsmPlacemarkData &outerBoundaryData = osmData.memberReference( index );
QVector<GeoDataCoordinates>::const_iterator it = outerBoundary.constBegin();
QVector<GeoDataCoordinates>::ConstIterator const end = outerBoundary.constEnd();
for ( ; it != end; ++it ) {
- if ( !osmData.memberReference( index ).containsNodeReference( *it ) ) {
- OsmPlacemarkData osmNodeData;
- osmNodeData.setId( --m_minId );
- outerBoundaryData.addNodeReference( *it, osmNodeData );
+ if (outerBoundaryData.nodeReference(*it).isNull()) {
+ outerBoundaryData.nodeReference(*it).setId(--m_minId);
}
}
// Each inner boundary
foreach( const GeoDataLinearRing &innerRing, polygon->innerBoundaries() ) {
++index;
- if ( !osmData.containsMemberReference( index ) ) {
- OsmPlacemarkData innerRingData;
- innerRingData.setId( --m_minId );
- osmData.addMemberReference( index, innerRingData );
+ OsmPlacemarkData &innerRingData = osmData.memberReference( index );
+ if (innerRingData.isNull()) {
+ innerRingData.setId(--m_minId);
}
// Inner boundary nodes
- OsmPlacemarkData &innerRingData = osmData.memberReference( index );
QVector<GeoDataCoordinates>::const_iterator it = innerRing.constBegin();
QVector<GeoDataCoordinates>::ConstIterator const end = innerRing.constEnd();
for ( ; it != end; ++it ) {
- if ( !osmData.memberReference( index ).containsNodeReference( *it ) ) {
- OsmPlacemarkData osmNodeData;
- osmNodeData.setId( --m_minId );
- innerRingData.addNodeReference( *it , osmNodeData );
+ if (innerRingData.nodeReference(*it).isNull()) {
+ innerRingData.nodeReference(*it).setId(--m_minId);
}
}
}