summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-10-01 13:07:53 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-10-01 13:11:08 (GMT)
commit58dee2489ae6464dda4c4d4d5bc827ec943f5a19 (patch)
treeac461f6929c8e468e1a6be457aa4e2c0c2c3b724
parent293df21652d0a244c3cc1f8d21f07265f69b0547 (diff)
Reduce geometry call overhead
-rw-r--r--tools/vectorosm-tilecreator/NodeReducer.cpp13
-rw-r--r--tools/vectorosm-tilecreator/VectorClipper.cpp21
2 files changed, 18 insertions, 16 deletions
diff --git a/tools/vectorosm-tilecreator/NodeReducer.cpp b/tools/vectorosm-tilecreator/NodeReducer.cpp
index 62bf91c..eff497b 100644
--- a/tools/vectorosm-tilecreator/NodeReducer.cpp
+++ b/tools/vectorosm-tilecreator/NodeReducer.cpp
@@ -30,24 +30,25 @@ NodeReducer::NodeReducer(GeoDataDocument* document, int zoomLevel) :
m_remainingNodes(0)
{
foreach (GeoDataPlacemark* placemark, placemarks()) {
+ GeoDataGeometry const * const geometry = placemark->geometry();
- if(placemark->geometry()->nodeType() == GeoDataTypes::GeoDataLineStringType) {
- GeoDataLineString* prevLine = static_cast<GeoDataLineString*>(placemark->geometry());
+ if(geometry->nodeType() == GeoDataTypes::GeoDataLineStringType) {
+ GeoDataLineString const * prevLine = static_cast<GeoDataLineString const *>(geometry);
GeoDataLineString* reducedLine = new GeoDataLineString;
reduce(prevLine, reducedLine);
placemark->setGeometry(reducedLine);
}
- else if(placemark->geometry()->nodeType() == GeoDataTypes::GeoDataLinearRingType) {
- GeoDataLinearRing* prevRing = static_cast<GeoDataLinearRing*>(placemark->geometry());
+ else if(geometry->nodeType() == GeoDataTypes::GeoDataLinearRingType) {
+ GeoDataLinearRing const * prevRing = static_cast<GeoDataLinearRing const *>(geometry);
GeoDataLinearRing* reducedRing = new GeoDataLinearRing;
reduce(prevRing, reducedRing);
placemark->setGeometry(reducedRing);
}
- else if(placemark->geometry()->nodeType() == GeoDataTypes::GeoDataPolygonType) {
+ else if(geometry->nodeType() == GeoDataTypes::GeoDataPolygonType) {
GeoDataPolygon* reducedPolygon = new GeoDataPolygon;
- GeoDataPolygon* prevPolygon = static_cast<GeoDataPolygon*>(placemark->geometry());
+ GeoDataPolygon const * prevPolygon = static_cast<GeoDataPolygon const *>(geometry);
GeoDataLinearRing const * prevRing = &(prevPolygon->outerBoundary());
GeoDataLinearRing reducedRing;
reduce(prevRing, &reducedRing);
diff --git a/tools/vectorosm-tilecreator/VectorClipper.cpp b/tools/vectorosm-tilecreator/VectorClipper.cpp
index ba19f2f..d307a79 100644
--- a/tools/vectorosm-tilecreator/VectorClipper.cpp
+++ b/tools/vectorosm-tilecreator/VectorClipper.cpp
@@ -43,13 +43,14 @@ GeoDataDocument *VectorClipper::clipTo(const GeoDataLatLonBox &tileBoundary)
GeoDataDocument* tile = new GeoDataDocument();
auto const clip = clipPath(tileBoundary);
- foreach (GeoDataPlacemark* placemark, placemarks()) {
- if(placemark && placemark->geometry() && tileBoundary.intersects(placemark->geometry()->latLonAltBox())) {
- if( placemark->geometry()->nodeType() == GeoDataTypes::GeoDataPolygonType) {
+ foreach (GeoDataPlacemark const * placemark, placemarks()) {
+ GeoDataGeometry const * const geometry = placemark ? placemark->geometry() : nullptr;
+ if(geometry && tileBoundary.intersects(geometry->latLonAltBox())) {
+ if(geometry->nodeType() == GeoDataTypes::GeoDataPolygonType) {
clipPolygon(placemark, clip, tile);
- } else if (placemark->geometry()->nodeType() == GeoDataTypes::GeoDataLineStringType) {
+ } else if (geometry->nodeType() == GeoDataTypes::GeoDataLineStringType) {
clipString<GeoDataLineString>(placemark, clip, tile);
- } else if (placemark->geometry()->nodeType() == GeoDataTypes::GeoDataLinearRingType) {
+ } else if (geometry->nodeType() == GeoDataTypes::GeoDataLinearRingType) {
clipString<GeoDataLinearRing>(placemark, clip, tile);
} else {
tile->append(new GeoDataPlacemark(*placemark));
@@ -66,12 +67,12 @@ GeoDataDocument *VectorClipper::clipToBaseClipper(const GeoDataLatLonBox &tileBo
BaseClipper clipper;
clipper.initClipRect(tileBoundary, 20);
- foreach (GeoDataPlacemark* placemark, placemarks()) {
+ foreach (GeoDataPlacemark const * placemark, placemarks()) {
if(placemark && placemark->geometry() && tileBoundary.intersects(placemark->geometry()->latLonAltBox())) {
if( placemark->geometry()->nodeType() == GeoDataTypes::GeoDataPolygonType) {
- GeoDataPolygon* marblePolygon = static_cast<GeoDataPolygon*>(placemark->geometry());
+ GeoDataPolygon const * marblePolygon = static_cast<GeoDataPolygon const *>(placemark->geometry());
int index = -1;
using PolygonPair = QPair<GeoDataPlacemark*, QPolygonF>;
@@ -122,7 +123,7 @@ GeoDataDocument *VectorClipper::clipToBaseClipper(const GeoDataLatLonBox &tileBo
OsmObjectManager::initializeOsmData(newMarblePolygon.first);
OsmPlacemarkData& innerRingData = newMarblePolygon.first->osmData().memberReference(geometry->innerBoundaries().size()-1);
- OsmPlacemarkData& placemarkInnerRingData = placemark->osmData().memberReference(index);
+ OsmPlacemarkData const & placemarkInnerRingData = placemark->osmData().memberReference(index);
copyTags(placemarkInnerRingData, innerRingData);
@@ -141,7 +142,7 @@ GeoDataDocument *VectorClipper::clipToBaseClipper(const GeoDataLatLonBox &tileBo
}
} else if (placemark->geometry()->nodeType() == GeoDataTypes::GeoDataLineStringType) {
- GeoDataLineString* marbleWay = static_cast<GeoDataLineString*>(placemark->geometry());
+ GeoDataLineString const * marbleWay = static_cast<GeoDataLineString const *>(placemark->geometry());
QVector<QPolygonF> clippedPolygons;
@@ -165,7 +166,7 @@ GeoDataDocument *VectorClipper::clipToBaseClipper(const GeoDataLatLonBox &tileBo
}
} else if (placemark->geometry()->nodeType() == GeoDataTypes::GeoDataLinearRingType) {
- GeoDataLinearRing* marbleClosedWay = static_cast<GeoDataLinearRing*>(placemark->geometry());
+ GeoDataLinearRing const * marbleClosedWay = static_cast<GeoDataLinearRing const *>(placemark->geometry());
QVector<QPolygonF> clippedPolygons;