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

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext
return_envelope (with strategy)

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, typename Strategy>
Box return_envelope(Geometry const & geometry, Strategy const & strategy)

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

Strategy const &

Any type fulfilling a Envelope Strategy Concept

strategy

The strategy which will be used for envelope calculations

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>

#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