Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext
is_simple (with strategy)

Checks if a geometry is simple.

Synopsis

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

Parameters

Type

Concept

Name

Description

Geometry const &

Any type fulfilling a Geometry Concept

geometry

A model of the specified concept

Strategy const &

Any type fulfilling a Is_simple Strategy Concept

strategy

The strategy which will be used for is_simple calculations

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

ok

Segment

ok

Box

ok

Linestring

ok

Ring

ok

Polygon

ok

MultiPoint

ok

MultiLinestring

ok

MultiPolygon

ok

Variant

ok

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

is_simple_example

See also

PrevUpHomeNext