summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-10-17 19:34:17 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-10-20 17:02:09 (GMT)
commit3cc478ed1d8f2ed558581b3276f502f155a495c9 (patch)
tree3a69a00afafab128fb4cacdc6fd8b622e216820f
parent3199b4f490bd4260aeba21d18e46f6427b38c79e (diff)
Do not treat closed line strings as polygons during clipping
Boundaries and other line strings can be closed, but need to be treated as open during clipping to prevent that a rectangular feature as large as the clip box is introduced when the clip box is fully contained within the line string. (cherry picked from commit aedbe275ce2162ad71b083f28a331d1c2ed04009)
-rw-r--r--tools/vectorosm-tilecreator/VectorClipper.cpp19
-rw-r--r--tools/vectorosm-tilecreator/VectorClipper.h3
2 files changed, 21 insertions, 1 deletions
diff --git a/tools/vectorosm-tilecreator/VectorClipper.cpp b/tools/vectorosm-tilecreator/VectorClipper.cpp
index cf0fc29..ef27cb5 100644
--- a/tools/vectorosm-tilecreator/VectorClipper.cpp
+++ b/tools/vectorosm-tilecreator/VectorClipper.cpp
@@ -281,6 +281,25 @@ ClipperLib::Path VectorClipper::clipPath(const GeoDataLatLonBox &box) const
return path;
}
+bool VectorClipper::canBeArea(GeoDataPlacemark::GeoDataVisualCategory visualCategory) const
+{
+ if (visualCategory >= GeoDataPlacemark::HighwaySteps && visualCategory <= GeoDataPlacemark::HighwayMotorway) {
+ return false;
+ }
+ if (visualCategory >= GeoDataPlacemark::RailwayRail && visualCategory <= GeoDataPlacemark::RailwayFunicular) {
+ return false;
+ }
+ if (visualCategory >= GeoDataPlacemark::AdminLevel1 && visualCategory <= GeoDataPlacemark::AdminLevel11) {
+ return false;
+ }
+
+ if (visualCategory == GeoDataPlacemark::BoundaryMaritime || visualCategory == GeoDataPlacemark::InternationalDateLine) {
+ return false;
+ }
+
+ return true;
+}
+
void VectorClipper::clipPolygon(const GeoDataPlacemark *placemark, const ClipperLib::Path &tileBoundary, GeoDataDocument *document)
{
const GeoDataPolygon* polygon = static_cast<const GeoDataPolygon*>(placemark->geometry());
diff --git a/tools/vectorosm-tilecreator/VectorClipper.h b/tools/vectorosm-tilecreator/VectorClipper.h
index fe7c6e3..30c42ce 100644
--- a/tools/vectorosm-tilecreator/VectorClipper.h
+++ b/tools/vectorosm-tilecreator/VectorClipper.h
@@ -37,6 +37,7 @@ private:
GeoDataDocument* clipToBaseClipper(const GeoDataLatLonBox &box);
QVector<GeoDataPlacemark*> potentialIntersections(const GeoDataLatLonBox &box) const;
ClipperLib::Path clipPath(const GeoDataLatLonBox &box) const;
+ bool canBeArea(GeoDataPlacemark::GeoDataVisualCategory visualCategory) const;
template<class T>
void clipString(const GeoDataPlacemark *placemark, const ClipperLib::Path &tileBoundary, GeoDataDocument* document)
@@ -50,7 +51,7 @@ private:
Clipper clipper;
clipper.PreserveCollinear(true);
- bool const isClosed = ring->isClosed();
+ bool const isClosed = ring->isClosed() && canBeArea(placemark->visualCategory());
clipper.AddPath(tileBoundary, ptClip, true);
clipper.AddPath(path, ptSubject, isClosed);
PolyTree tree;