summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-11-13 18:31:36 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-11-13 18:31:36 (GMT)
commit660c528cb5683506107fb129ab958964b270539a (patch)
tree46ce19036da6bd5b773eeca72510f9917e9d7c0e
parent40c0e937df2c75b9ca9651e6026ffe1483cf071e (diff)
Simplify less.
-rw-r--r--tools/vectorosm-tilecreator/NodeReducer.cpp19
-rw-r--r--tools/vectorosm-tilecreator/NodeReducer.h5
2 files changed, 12 insertions, 12 deletions
diff --git a/tools/vectorosm-tilecreator/NodeReducer.cpp b/tools/vectorosm-tilecreator/NodeReducer.cpp
index 6eadc9d..f3b2d7c 100644
--- a/tools/vectorosm-tilecreator/NodeReducer.cpp
+++ b/tools/vectorosm-tilecreator/NodeReducer.cpp
@@ -29,6 +29,9 @@ NodeReducer::NodeReducer(GeoDataDocument* document, int zoomLevel) :
m_remainingNodes(0)
{
foreach (GeoDataPlacemark* placemark, placemarks()) {
+ if (placemark->visualCategory() == GeoDataPlacemark::None) {
+ continue;
+ }
GeoDataGeometry const * const geometry = placemark->geometry();
if(geometry->nodeType() == GeoDataTypes::GeoDataLineStringType) {
GeoDataLineString const * prevLine = static_cast<GeoDataLineString const *>(geometry);
@@ -66,19 +69,17 @@ qint64 NodeReducer::remainingNodes() const
return m_remainingNodes;
}
-qreal NodeReducer::epsilonForString(int detailLevel) const
+qreal NodeReducer::epsilonFor(int detailLevel, qreal multiplier) const
{
if (detailLevel >= 17) {
return 0.25;
+ } else if (detailLevel >= 10) {
+ int const factor = 1 << (qAbs(detailLevel-12));
+ return multiplier / factor;
+ } else {
+ int const factor = 1 << (qAbs(detailLevel-12));
+ return multiplier * factor;
}
- int const factor = 1 << (qAbs(detailLevel-11));
- return detailLevel < 12 ? 30.0 * factor : 30.0 / factor;
-}
-
-qreal NodeReducer::epsilonForArea(int detailLevel) const
-{
- int const factor = 1 << (qAbs(detailLevel-11));
- return detailLevel < 12 ? 60.0 * factor : 60.0 / factor;
}
qreal NodeReducer::perpendicularDistance(const GeoDataCoordinates &a, const GeoDataCoordinates &b, const GeoDataCoordinates &c) const
diff --git a/tools/vectorosm-tilecreator/NodeReducer.h b/tools/vectorosm-tilecreator/NodeReducer.h
index b0b9bd4..0be0a05 100644
--- a/tools/vectorosm-tilecreator/NodeReducer.h
+++ b/tools/vectorosm-tilecreator/NodeReducer.h
@@ -26,15 +26,14 @@ public:
qint64 remainingNodes() const;
private:
- qreal epsilonForString(int detailLevel) const;
- qreal epsilonForArea(int detailLevel) const;
+ qreal epsilonFor(int detailLevel, qreal multiplier) const;
qreal perpendicularDistance(const GeoDataCoordinates &a, const GeoDataCoordinates &b, const GeoDataCoordinates &c) const;
template<class T>
void reduce(T const & lineString, const GeoDataPlacemark* placemark, T* reducedLine, int tileLevel)
{
bool const isArea = lineString.isClosed() && VectorClipper::canBeArea(placemark->visualCategory());
- qreal const epsilon = isArea ? epsilonForArea(tileLevel) : epsilonForString(tileLevel);
+ qreal const epsilon = epsilonFor(tileLevel, isArea ? 45.0 : 30.0);
*reducedLine = douglasPeucker(lineString, placemark->osmData(), epsilon);
qint64 prevSize = lineString.size();