File: custom_lon_lat_point.hpp

package info (click to toggle)
boost1.74 1.74.0-9
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 464,084 kB
  • sloc: cpp: 3,338,324; xml: 131,293; python: 33,088; ansic: 14,336; asm: 4,034; sh: 3,351; makefile: 1,193; perl: 1,036; yacc: 478; php: 212; ruby: 102; lisp: 24; sql: 13; csh: 6
file content (133 lines) | stat: -rw-r--r-- 3,647 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Unit Test

// Copyright (c) 2014, Oracle and/or its affiliates.

// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle

// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html

#ifndef BOOST_GEOMETRY_TEST_TEST_GEOMETRIES_CUSTOM_LON_LAT_POINT_HPP
#define BOOST_GEOMETRY_TEST_TEST_GEOMETRIES_CUSTOM_LON_LAT_POINT_HPP

#include <boost/mpl/int.hpp>

#include <boost/geometry/core/access.hpp>
#include <boost/geometry/core/coordinate_dimension.hpp>
#include <boost/geometry/core/coordinate_system.hpp>
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>


// read/write longitude/latitude point
template <typename CoordinateType, typename CoordinateSystem>
struct rw_lon_lat_point
{
    CoordinateType longitude, latitude; 
};


namespace boost { namespace geometry { namespace traits
{
template <typename CoordinateType, typename CoordinateSystem>
struct tag<rw_lon_lat_point<CoordinateType, CoordinateSystem> >
{
    typedef point_tag type;
};

template <typename CoordinateType, typename CoordinateSystem>
struct coordinate_type<rw_lon_lat_point<CoordinateType, CoordinateSystem> >
{
    typedef CoordinateType type;
};

template <typename CoordinateType, typename CoordinateSystem>
struct coordinate_system<rw_lon_lat_point<CoordinateType, CoordinateSystem> >
{
    typedef CoordinateSystem type;
};

template <typename CoordinateType, typename CoordinateSystem>
struct dimension<rw_lon_lat_point<CoordinateType, CoordinateSystem> >
    : boost::mpl::int_<2>
{};

template
<
    typename CoordinateType,
    typename CoordinateSystem,
    std::size_t Dimension
>
struct access<rw_lon_lat_point<CoordinateType, CoordinateSystem>, Dimension>
{
    static inline CoordinateType
    get(rw_lon_lat_point<CoordinateType, CoordinateSystem> const& p)
    {
        return (Dimension == 0) ? p.longitude : p.latitude;
    }

    static inline
    void set(rw_lon_lat_point<CoordinateType, CoordinateSystem>& p,
             CoordinateType const& value)
    {
        ( Dimension == 0 ? p.longitude : p.latitude ) = value;
    }
};

}}} // namespace boost::geometry::traits


// read-only longitude/latitude point
template <typename CoordinateType, typename CoordinateSystem>
struct ro_lon_lat_point
{
    CoordinateType longitude, latitude; 
};


namespace boost { namespace geometry { namespace traits
{
template <typename CoordinateType, typename CoordinateSystem>
struct tag<ro_lon_lat_point<CoordinateType, CoordinateSystem> >
{
    typedef point_tag type;
};

template <typename CoordinateType, typename CoordinateSystem>
struct coordinate_type<ro_lon_lat_point<CoordinateType, CoordinateSystem> >
{
    typedef CoordinateType type;
};

template <typename CoordinateType, typename CoordinateSystem>
struct coordinate_system<ro_lon_lat_point<CoordinateType, CoordinateSystem> >
{
    typedef CoordinateSystem type;
};

template <typename CoordinateType, typename CoordinateSystem>
struct dimension<ro_lon_lat_point<CoordinateType, CoordinateSystem> >
    : boost::mpl::int_<2>
{};

template
<
    typename CoordinateType,
    typename CoordinateSystem,
    std::size_t Dimension
>
struct access<ro_lon_lat_point<CoordinateType, CoordinateSystem>, Dimension>
{
    static inline CoordinateType
    get(ro_lon_lat_point<CoordinateType, CoordinateSystem> const& p)
    {
        return (Dimension == 0) ? p.longitude : p.latitude;
    }
};

}}} // namespace boost::geometry::traits


#endif // BOOST_GEOMETRY_TEST_TEST_GEOMETRIES_CUSTOM_LON_LAT_POINT_HPP