1// Boost.Geometry (aka GGL, Generic Geometry Library)
2
3// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
4// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
5// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
6
7// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
8// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
9
10// Use, modification and distribution is subject to the Boost Software License,
11// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12// http://www.boost.org/LICENSE_1_0.txt)
13
14#ifndef BOOST_GEOMETRY_CORE_COORDINATE_TYPE_HPP
15#define BOOST_GEOMETRY_CORE_COORDINATE_TYPE_HPP
16
17
18#include <boost/mpl/assert.hpp>
19
20#include <boost/geometry/core/tag.hpp>
21#include <boost/geometry/core/point_type.hpp>
22#include <boost/geometry/util/bare_type.hpp>
23#include <boost/geometry/util/promote_floating_point.hpp>
24
25
26namespace boost { namespace geometry
27{
28
29namespace traits
30{
31
32/*!
33\brief Traits class which indicate the coordinate type (double,float,...) of a point
34\ingroup traits
35\par Geometries:
36 - point
37\par Specializations should provide:
38 - typedef T type; (double,float,int,etc)
39*/
40template <typename Point, typename Enable = void>
41struct coordinate_type
42{
43 BOOST_MPL_ASSERT_MSG
44 (
45 false, NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE, (types<Point>)
46 );
47};
48
49} // namespace traits
50
51#ifndef DOXYGEN_NO_DISPATCH
52namespace core_dispatch
53{
54
55template <typename GeometryTag, typename Geometry>
56struct coordinate_type
57{
58 typedef typename point_type<GeometryTag, Geometry>::type point_type;
59
60 // Call its own specialization on point-tag
61 typedef typename coordinate_type<point_tag, point_type>::type type;
62};
63
64template <typename Point>
65struct coordinate_type<point_tag, Point>
66{
67 typedef typename traits::coordinate_type
68 <
69 typename geometry::util::bare_type<Point>::type
70 >::type type;
71};
72
73
74} // namespace core_dispatch
75#endif // DOXYGEN_NO_DISPATCH
76
77
78/*!
79\brief \brief_meta{type, coordinate type (int\, float\, double\, etc), \meta_point_type}
80\tparam Geometry \tparam_geometry
81\ingroup core
82
83\qbk{[include reference/core/coordinate_type.qbk]}
84*/
85template <typename Geometry>
86struct coordinate_type
87{
88 typedef typename core_dispatch::coordinate_type
89 <
90 typename tag<Geometry>::type,
91 typename geometry::util::bare_type<Geometry>::type
92 >::type type;
93};
94
95template <typename Geometry>
96struct fp_coordinate_type
97{
98 typedef typename promote_floating_point
99 <
100 typename coordinate_type<Geometry>::type
101 >::type type;
102};
103
104
105}} // namespace boost::geometry
106
107
108#endif // BOOST_GEOMETRY_CORE_COORDINATE_TYPE_HPP
109