|  | Home | Libraries | People | FAQ | More | 
template<typename Geometry, typename Distance> void simplify(Geometry const & geometry, Geometry & out, Distance const & max_distance)
| Type | Concept | Name | Description | 
|---|---|---|---|
| Geometry const & | Any type fulfilling a Geometry Concept | geometry | input geometry, to be simplified | 
| Geometry & | Any type fulfilling a Geometry Concept | out | output geometry, simplified version of the input geometry | 
| Distance const & | numerical type (int, double, ttmath, ...) | max_distance | distance (in units of input coordinates) of a vertex to other segments to be removed | 
Either
            #include <boost/geometry.hpp>
          
Or
            #include <boost/geometry/algorithms/simplify.hpp>
          
The function simplify is not defined by OGC.
| ![[Note]](../../../../../../../../doc/src/images/note.png) | Note | 
|---|---|
| PostGIS contains an algorithm with the same name and the same functionality. See the PostGIS documentation. | 
| ![[Note]](../../../../../../../../doc/src/images/note.png) | Note | 
|---|---|
| SQL Server contains an algorithm Reduce() with the same functionality. See the MSDN documentation. | 
Simplification is done using Douglas-Peucker (if the default strategy is used).
| ![[Note]](../../../../../../../../doc/src/images/note.png) | Note | 
|---|---|
| Geometries might become invalid by using simplify. The simplification process might create self-intersections. | 
Example showing how to simplify a linestring
#include <iostream> #include <boost/geometry.hpp> #include <boost/geometry/geometries/linestring.hpp> #include <boost/geometry/geometries/point_xy.hpp>#include <boost/assign.hpp> using namespace boost::assign; int main() { typedef boost::geometry::model::d2::point_xy<double> xy; boost::geometry::model::linestring<xy> line; line += xy(1.1, 1.1), xy(2.5, 2.1), xy(3.1, 3.1), xy(4.9, 1.1), xy(3.1, 1.9);
// Simplify it, using distance of 0.5 units boost::geometry::model::linestring<xy> simplified; boost::geometry::simplify(line, simplified, 0.5); std::cout << " original: " << boost::geometry::dsv(line) << std::endl << "simplified: " << boost::geometry::dsv(simplified) << std::endl; return 0; }
Output:
original: ((1.1, 1.1), (2.5, 2.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9)) simplified: ((1.1, 1.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9))
            