| Home | Libraries | People | FAQ | More

##### simplify

Simplify a geometry.

###### Synopsis

    template<typename Geometry, typename Distance>
    void simplify(Geometry const & geometry, Geometry & out, Distance const & max_distance)

###### Parameters

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

###### Header

Either

`#include <boost/geometry/geometry.hpp>`

Or

`#include <boost/geometry/algorithms/simplify.hpp>`

###### Examples

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;
    }

| For this example we use Boost.Assign to add points
| With Boost.Assign

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))

###### Image(s)