is_simple

| Home | Libraries | People | FAQ | More

#### is_simple

Checks if a geometry is simple.

###### Synopsis

    template<typename Geometry>
    bool is_simple(Geometry const & geometry)

###### Parameters

Type | Concept | Name | Description
--- | --- | --- | ---
Geometry const & | Any type fulfilling a Geometry Concept | geometry | A model of the specified concept

###### Returns

Returns true if the geometry is simple

###### Header

Either

`#include <boost/geometry.hpp>`

Or

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

###### Conformance

The function is_simple implements function IsSimple from the OGC Simple Feature Specification.

###### Supported geometries

Geometry | Status
--- | ---
Point |
Segment |
Box |
Linestring |
Ring |
Polygon |
MultiPoint |
MultiLinestring |
MultiPolygon |
Variant |

###### Complexity

Constant-time for points, segments and boxes

Linear for rings, polygons and multi-polygons

Linearithmic for multi-points, linestrings and multi-linestrings

###### Example

Checks whether a geometry is simple

    #include <iostream>

    #include <boost/geometry.hpp>
    #include <boost/geometry/geometries/point_xy.hpp>
    #include <boost/geometry/geometries/linestring.hpp>
    #include <boost/geometry/geometries/multi_linestring.hpp>

    int main()
    {
        typedef boost::geometry::model::d2::point_xy<double> point_type;
        typedef boost::geometry::model::linestring<point_type> linestring_type;
        typedef boost::geometry::model::multi_linestring<linestring_type> multi_linestring_type;

        multi_linestring_type multi_linestring;
        boost::geometry::read_wkt("MULTILINESTRING((0 0,0 10,10 10,10 0,0 0),(10 10,20 20))", multi_linestring);

        std::cout << "is simple? "
                  << (boost::geometry::is_simple(multi_linestring) ? "yes" : "no")
                  << std::endl;

        return 0;
    }

Output:

    is simple? no

###### See also

- is_valid