| Home | Libraries | People | FAQ | More

##### return_envelope

Calculates the envelope of a geometry.

###### Description

The free function return_envelope calculates the envelope (also known as axis aligned bounding box, aabb, or minimum bounding rectangle, mbr) of a geometry. This version with the return_ prefix returns the envelope, and a template parameter must therefore be specified in the call.

###### Synopsis

    template<typename Box, typename Geometry>
    Box return_envelope(Geometry const & geometry)

###### Parameters

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

###### Returns

The calculated envelope

###### Header

Either

`#include <boost/geometry.hpp>`

Or

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

###### Conformance

The function envelope implements function Envelope from the OGC Simple Feature Specification.

###### Example

Shows how to return the envelope of a ring

    #include <iostream>

    #include <boost/geometry.hpp>
    #include <boost/geometry/geometries/box.hpp>
    #include <boost/geometry/geometries/point_xy.hpp>
    #include <boost/geometry/geometries/ring.hpp>

    int main()
    {
        using point = boost::geometry::model::d2::point_xy<double>;
        using box = boost::geometry::model::box<point>;

        const boost::geometry::model::ring<point> ring {
            {4.0, -0.5}, {3.5, 1.0}, {2.0, 1.5}, {3.5, 2.0},
            {4.0, 3.5}, {4.5, 2.0}, {6.0, 1.5}, {4.5, 1.0},
            {4.0, -0.5}
        };

        std::cout
            << "return_envelope:"
            << boost::geometry::dsv(boost::geometry::return_envelope<box>(ring))
            << std::endl;

        return 0;
    }

Output:

    return_envelope:((2, -0.5), (6, 3.5))