| Home | Libraries | People | FAQ | More

##### intersects (with strategy)

Checks if two geometries have at least one intersection.

###### Synopsis

    template<typename Geometry1, typename Geometry2, typename Strategy>
    bool intersects(Geometry1 const & geometry1, Geometry2 const & geometry2, Strategy const & strategy)

###### Parameters

Type | Concept | Name | Description
--- | --- | --- | ---
Geometry1 const & | Any type fulfilling a Geometry Concept | geometry1 | A model of the specified concept
Geometry2 const & | Any type fulfilling a Geometry Concept | geometry2 | A model of the specified concept
Strategy const & | Any type fulfilling a Intersects Strategy Concept | strategy | The strategy which will be used for intersects calculations

###### Returns

Returns true if two geometries intersect each other

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