| Home | Libraries | People | FAQ | More

##### intersects (one geometry)

Checks if a geometry has at least one intersection (crossing or self-tangency)

###### Synopsis

    template<typename Geometry>
    bool intersects(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 self-intersecting

###### Header

Either

`#include <boost/geometry.hpp>`

Or

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

###### Conformance

The function intersects implements function Intersects from the OGC Simple Feature Specification.

The version with one parameter is additional and not described in the OGC standard

###### Examples

Check if two linestrings intersect each other

    #include <iostream>

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

    int main()
    {
        // Calculate the intersects of a cartesian polygon
        typedef boost::geometry::model::d2::point_xy<double> P;
        boost::geometry::model::linestring<P> line1, line2;

        boost::geometry::read_wkt("linestring(1 1,2 2,3 3)", line1);
        boost::geometry::read_wkt("linestring(2 1,1 2,4 0)", line2);

        bool b = boost::geometry::intersects(line1, line2);

        std::cout << "Intersects: " << (b ? "YES" : "NO") << std::endl;

        return 0;
    }

Output:

    Intersects: YES