summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-09-11 05:12:15 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-09-11 05:53:40 (GMT)
commit792a609668e8e34a6cd2bdeb021e9f36316b3948 (patch)
treeef06763f6113f2358164bf121a486be524b82af9
parente929bbcb89d64aec0dd3487d88e3f771d0ca340b (diff)
Extract method clipTo(GeoDataLatLonBox)
-rw-r--r--tools/vectorosm-tilecreator/TinyPlanetProcessor.cpp36
-rw-r--r--tools/vectorosm-tilecreator/TinyPlanetProcessor.h3
2 files changed, 23 insertions, 16 deletions
diff --git a/tools/vectorosm-tilecreator/TinyPlanetProcessor.cpp b/tools/vectorosm-tilecreator/TinyPlanetProcessor.cpp
index 495cea1..1c46166 100644
--- a/tools/vectorosm-tilecreator/TinyPlanetProcessor.cpp
+++ b/tools/vectorosm-tilecreator/TinyPlanetProcessor.cpp
@@ -34,28 +34,15 @@ void TinyPlanetProcessor::process()
// ?
}
-GeoDataDocument *TinyPlanetProcessor::cutToTiles(unsigned int zoomLevel, unsigned int tileX, unsigned int tileY)
+GeoDataDocument *TinyPlanetProcessor::clipTo(const GeoDataLatLonBox &tileBoundary)
{
- unsigned int N = pow(2, zoomLevel);
-
GeoDataDocument* tile = new GeoDataDocument();
- QString tileName = QString("%1/%2/%3").arg(zoomLevel).arg(tileX).arg(tileY);
- tile->setName(tileName);
-
- GeoDataLatLonBox tileBoundary;
- qreal north = BaseClipper::tileY2lat(tileY, N);
- qreal south = BaseClipper::tileY2lat(tileY+1, N);
- qreal west = BaseClipper::tileX2lon(tileX, N);
- qreal east = BaseClipper::tileX2lon(tileX+1, N);
-
- tileBoundary.setBoundaries(north, south, east, west);
-
BaseClipper clipper;
clipper.initClipRect(tileBoundary, 20);
foreach (GeoDataPlacemark* placemark, placemarks()) {
- if(tileBoundary.intersects(placemark->geometry()->latLonAltBox())) {
+ if(placemark && placemark->geometry() && tileBoundary.intersects(placemark->geometry()->latLonAltBox())) {
if( placemark->geometry()->nodeType() == GeoDataTypes::GeoDataPolygonType) {
GeoDataPolygon* marblePolygon = static_cast<GeoDataPolygon*>(placemark->geometry());
@@ -175,7 +162,7 @@ GeoDataDocument *TinyPlanetProcessor::cutToTiles(unsigned int zoomLevel, unsigne
}
} else {
- tile->append(placemark);
+ tile->append(new GeoDataPlacemark(*placemark));
}
}
}
@@ -184,6 +171,23 @@ GeoDataDocument *TinyPlanetProcessor::cutToTiles(unsigned int zoomLevel, unsigne
return tile;
}
+GeoDataDocument *TinyPlanetProcessor::cutToTiles(unsigned int zoomLevel, unsigned int tileX, unsigned int tileY)
+{
+ unsigned int N = pow(2, zoomLevel);
+ GeoDataLatLonBox tileBoundary;
+ qreal north = TileId::tileY2lat(tileY, N);
+ qreal south = TileId::tileY2lat(tileY+1, N);
+ qreal west = TileId::tileX2lon(tileX, N);
+ qreal east = TileId::tileX2lon(tileX+1, N);
+ tileBoundary.setBoundaries(north, south, east, west);
+
+ GeoDataDocument *tile = clipTo(tileBoundary);
+ QString tileName = QString("%1/%2/%3").arg(zoomLevel).arg(tileX).arg(tileY);
+ tile->setName(tileName);
+
+ return tile;
+}
+
void TinyPlanetProcessor::copyTags(const GeoDataPlacemark &source, GeoDataPlacemark &target) const
{
copyTags(source.osmData(), target.osmData());
diff --git a/tools/vectorosm-tilecreator/TinyPlanetProcessor.h b/tools/vectorosm-tilecreator/TinyPlanetProcessor.h
index 27df005..0fedd5a 100644
--- a/tools/vectorosm-tilecreator/TinyPlanetProcessor.h
+++ b/tools/vectorosm-tilecreator/TinyPlanetProcessor.h
@@ -14,6 +14,8 @@
#include "PlacemarkFilter.h"
#include "OsmPlacemarkData.h"
+#include <GeoDataLatLonBox.h>
+
namespace Marble {
class TinyPlanetProcessor : public PlacemarkFilter
@@ -23,6 +25,7 @@ public:
void process() override;
+ GeoDataDocument* clipTo(const GeoDataLatLonBox &box);
GeoDataDocument* cutToTiles(unsigned int zoomLevel, unsigned int tileX, unsigned int tileY);
private: