| Home | Libraries | People | FAQ | More

##### relate

Checks relation between a pair of geometries defined by a mask.

###### Synopsis

    template<typename Geometry1, typename Geometry2, typename Mask>
    bool relate(Geometry1 const & geometry1, Geometry2 const & geometry2, Mask const & mask)

###### 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
Mask const & | An intersection model Mask type. | mask | An intersection model mask object.

###### Returns

true if the relation is compatible with the mask, false otherwise.

###### Header

Either

`#include <boost/geometry.hpp>`

Or

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

###### Conformance

The function relate implements function Relate from the OGC Simple Feature Specification.

###### Example

Shows how to detect if a point is inside a polygon, or not

    #include <iostream>

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

    int main()
    {
        typedef boost::geometry::model::d2::point_xy<double> point_type;
        typedef boost::geometry::model::polygon<point_type> polygon_type;

        polygon_type poly;
        boost::geometry::read_wkt(
            "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3)"
                "(4.0 2.0, 4.2 1.4, 4.8 1.9, 4.4 2.2, 4.0 2.0))", poly);

        point_type p(4, 1);

        boost::geometry::de9im::mask mask("T*F**F***"); // within
        bool check = boost::geometry::relate(p, poly, mask);

        std::cout << "relate: " << (check ? "yes" : "no") << std::endl;

        return 0;
    }

Output:

    relate: yes

###### See also

- de9im::mask
- de9im::static_mask
- relation