template<typename Geometry>
class boost::geometry::concepts::Point< Geometry >
Point concept.
- Formal definition:
- The point concept is defined as following:
- 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:
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; }
};
}}}
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: