GGL    Boost C++ Libraries

area: calculate area of a geometry


Classes

struct  ggl::area_result< Geometry >
 Meta-function defining return type of area function. More...
class  ggl::concept::AreaStrategy< Strategy >
 Checks strategy for area. More...
struct  ggl::strategy_area< Tag, PointOfSegment >
 Traits class binding an area strategy to a coordinate system. More...

Functions

template<typename Geometry , typename Strategy >
Strategy::return_type ggl::area (Geometry const &geometry, Strategy const &strategy)
 Calculate area of a geometry using a specified strategy.
template<typename Geometry >
area_result< Geometry >::type ggl::area (Geometry const &geometry)
 Calculate area of a geometry.

Detailed Description

Performance
2776 * 1000 area calculations are done in 0.11 seconds (http://trac.osgeo.org/ggl/wiki/Performance#Area1)
Coordinate systems and strategies
Area calculation can be done in Cartesian and in spherical/geographic coordinate systems.
Geometries
The area algorithm calculates the surface area of all geometries having a surface: box, polygon, multi_polygon. The units are the square of the units used for the points defining the surface. If the polygon is defined in meters, the area is in square meters.
Example:
Example showing area calculation of polygons built
{
    ggl::polygon<ggl::point_xy<double> > poly;
    ggl::read_wkt("POLYGON((0 0,0 7,4 2,2 0,0 0))", poly);
    std::cout << "Polygon area is "
        << ggl::area(poly)
        << " square units" << std::endl;

    // Other coordinate system, spherical or geographic (extension)
    ggl::polygon<ggl::point<float, 2, ggl::cs::spherical<ggl::degree> > > sph_poly;
    ggl::read_wkt("POLYGON((0 0,0 45,45 0,0 0))", sph_poly);
    std::cout << "Area is "
        << ggl::area(sph_poly)
        << " on unit sphere " << std::endl;
}

Function Documentation

template<typename Geometry >
area_result<Geometry>::type ggl::area ( Geometry const &  geometry  ) 

Calculate area of a geometry.

The function area returns the area of a polygon, ring, box using the default area-calculation strategy. Strategies are provided for cartesian and spherical coordinate systems The geometries should correct, polygons should be closed and according to the specified orientation (clockwise/counter clockwise)

Parameters:
geometry a geometry
Returns:
the area
Examples:
03_polygon_example.cpp, c04_a_custom_triangle_example.cpp, c04_b_custom_triangle_example.cpp, x01_qt_example.cpp, x02_numeric_adaptor_example.cpp, and x03_d_soci_example.cpp.

Definition at line 218 of file area.hpp.

template<typename Geometry , typename Strategy >
Strategy::return_type ggl::area ( Geometry const &  geometry,
Strategy const &  strategy 
)

Calculate area of a geometry using a specified strategy.

This version of area calculation takes a strategy

Parameters:
geometry a geometry
strategy the strategy to calculate area. Especially for spherical areas there are some approaches.
Returns:
the area

Definition at line 243 of file area.hpp.


November 5, 2009

Copyright © 1995-2009 Barend Gehrels, Geodan, Amsterdam
Copyright © 2008-2009 Bruno Lalande, Paris
Copyright © 2009 Mateusz Loskot, Cadcorp, London
Documentation is generated by Doxygen