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

PrevUpHomeNext
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/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>

#include <boost/assign.hpp>



int main()
{
    using namespace boost::assign;

    typedef boost::geometry::model::d2::point_xy<double> point;

    boost::geometry::model::ring<point> ring;
    ring +=
        point(4.0, -0.5), point(3.5, 1.0),
        point(2.0, 1.5), point(3.5, 2.0),
        point(4.0, 3.5), point(4.5, 2.0),
        point(6.0, 1.5), point(4.5, 1.0),
        point(4.0, -0.5);

    typedef boost::geometry::model::box<point> box;

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

return_envelope

PrevUpHomeNext