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

Click here to view the latest version of this page.
PrevUpHomeNext

dimension

Metafunction defining value as the number of coordinates (the number of axes of any geometry) of the point type making up the specified geometry type.

Synopsis

template<typename Geometry>
struct dimension
{
  // ...
};

Template parameter(s)

Parameter

Description

typename Geometry

Any type fulfilling a Geometry Concept

Header

#include <boost/geometry/core/coordinate_dimension.hpp>

Complexity

Compile time

Example

Examine the number of coordinates making up the points in a linestring type

#include <iostream>

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/linestring.hpp>
#include <boost/geometry/geometries/adapted/boost_tuple.hpp>

BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian);

int main()
{
    int dim = boost::geometry::dimension
        <
            boost::geometry::model::linestring
                <
                    boost::tuple<float, float, float>
                >
        >::value;

    std::cout << "dimensions: " << dim << std::endl;

    return 0;
}

Output:

dimensions: 3

PrevUpHomeNext