diff --git a/doc/stages/filters.hexbin.rst b/doc/stages/filters.hexbin.rst index 0f298c9806..541979c054 100644 --- a/doc/stages/filters.hexbin.rst +++ b/doc/stages/filters.hexbin.rst @@ -117,3 +117,9 @@ threshold precision Minimum number of significant digits to use in writing out the well-known text of the boundary polygon. [Default: 8] + +preserve_topology + Use GEOS SimplifyPreserveTopology instead of Simplify for polygon simplification with `smooth` option. [Default: true] + +smooth + Use GEOS simplify operations to smooth boundary to a tolerance [Default: true] diff --git a/filters/HexBinFilter.cpp b/filters/HexBinFilter.cpp index 35827f5dbe..92c46e7b6a 100644 --- a/filters/HexBinFilter.cpp +++ b/filters/HexBinFilter.cpp @@ -83,6 +83,7 @@ void HexBin::addArgs(ProgramArgs& args) m_cullArg = &args.add("hole_cull_area_tolerance", "Tolerance area to " "apply to holes before cull", m_cullArea); args.add("smooth", "Smooth boundary output", m_doSmooth, true); + args.add("preserve_topology", "Preserve topology when smoothing", m_preserve_topology, true); } diff --git a/filters/HexBinFilter.hpp b/filters/HexBinFilter.hpp index 13b6d69c35..c4223a0323 100644 --- a/filters/HexBinFilter.hpp +++ b/filters/HexBinFilter.hpp @@ -71,6 +71,7 @@ class PDAL_DLL HexBin : public Filter, public Streamable bool m_outputTesselation; bool m_doSmooth; point_count_t m_count; + bool m_preserve_topology; virtual void addArgs(ProgramArgs& args); virtual void ready(PointTableRef table); diff --git a/pdal/Polygon.cpp b/pdal/Polygon.cpp index 530dd46e98..2a16cb7162 100644 --- a/pdal/Polygon.cpp +++ b/pdal/Polygon.cpp @@ -88,7 +88,7 @@ Polygon::Polygon(const BOX3D& box) } -void Polygon::simplify(double distance_tolerance, double area_tolerance) +void Polygon::simplify(double distance_tolerance, double area_tolerance, bool preserve_topology) { throwNoGeos(); @@ -114,7 +114,12 @@ void Polygon::simplify(double distance_tolerance, double area_tolerance) OGR_G_RemoveGeometry(gdal::toHandle(poly), i, true); }; - OGRGeometry *g = m_geom->SimplifyPreserveTopology(distance_tolerance); + OGRGeometry *g; + if (preserve_topology) + g = m_geom->SimplifyPreserveTopology(distance_tolerance); + else + g = m_geom->Simplify(distance_tolerance); + m_geom.reset(g); OGRwkbGeometryType t = m_geom->getGeometryType(); diff --git a/pdal/Polygon.hpp b/pdal/Polygon.hpp index e1f9d44816..ebca9f9dbd 100644 --- a/pdal/Polygon.hpp +++ b/pdal/Polygon.hpp @@ -62,7 +62,7 @@ class PDAL_DLL Polygon : public Geometry OGRGeometryH getOGRHandle(); - void simplify(double distance_tolerance, double area_tolerance); + void simplify(double distance_tolerance, double area_tolerance, bool preserve_topology = true); double area() const; std::vector polygons() const;