boost::geometry::concept::Point< Geometry > Class Template Reference
geometry concepts: defines and checks concepts for geometries

Point concept. More...

## Detailed Description

### template<typename Geometry>
class boost::geometry::concept::Point< Geometry >

Point concept.

Formal definition:
  The point concept is defined as following:
  - there must be a specialization of traits::tag defining point_tag as type
  - there must be a specialization of traits::coordinate_type defining the type of its coordinates
  - there must be a specialization of traits::coordinate_system defining its coordinate system (cartesian, spherical, etc)
  - there must be a specialization of traits::dimension defining its number of dimensions (2, 3, ...) (derive it conveniently from boost::mpl::int_<X> for X-D)
  - there must be a specialization of traits::access, per dimension, with two functions:
    - get to get a coordinate value
    - set to set a coordinate value (this one is not checked for ConstPoint)
  - for non-Cartesian coordinate systems, the coordinate system's units must either be boost::geometry::degree or boost::geometry::radian

Example:

A legacy point, defining the necessary specializations to fulfil to the concept.

Suppose that the following point is defined:

    struct legacy_point1
    {
        double x, y;
    };

It can then be adapted to the concept as following:

    // adapt legacy_point1
    namespace boost { namespace geometry { namespace traits
    {
        template <> struct tag<legacy_point1> { typedef point_tag type; };
        template <> struct coordinate_type<legacy_point1> { typedef double type; };
        template <> struct coordinate_system<legacy_point1> { typedef cs::cartesian type; };
        template <> struct dimension<legacy_point1>: boost::mpl::int_<2> {};
        template <> struct access<legacy_point1, 0>
        {
            static double get(legacy_point1 const& p) { return p.x; }
            static void set(legacy_point1& p, double const& value) { p.x = value; }
        };
        template <> struct access<legacy_point1, 1>
        {
            static double get(legacy_point1 const& p) { return p.y; }
            static void set(legacy_point1& p, double const& value) { p.y = value; }
        };
    }}} // namespace boost::geometry::traits

Note that it is done like above to show the system. Users will normally use the registration macro.

Example:

A read-only legacy point, using a macro to fulfil to the ConstPoint concept. It cannot be modified by the library but can be used in all algorithms where points are not modified.

The point looks like the following:

    class legacy_point2
    {
    public :
        double x() const;
        double y() const;
    };

It uses the macro as following:

    // adapt legacy_point2
    BOOST_GEOMETRY_REGISTER_POINT_2D_CONST(legacy_point2, double, boost::geometry::cs::cartesian, x(), y() )
    // end adaptation

April 2, 2011 | Copyright © 2007-2011 Barend Gehrels, Amsterdam, the Netherlands Copyright © 2008-2011 Bruno Lalande, Paris, France Copyright © 2009-2010 Mateusz Loskot, London, UK