summaryrefslogtreecommitdiffstats
path: root/server/src/geo/utm_zone_local.cppm
blob: b2147ad723c897fcf9b1d234a77cd7c9d57de75d (about) (plain) (blame)
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
module;

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/register/linestring.hpp>

export module routemon:geo.utm.zone_local;

import :geo;
import :geo.utm;

// Coordinates that are local to some known UTM zone.
namespace routemon::geo::utm::zone_local {

using cs = bgeo::cs::cartesian;

namespace prim {

using point = bgeo::model::d2::point_xy<double>;
using linestring = bgeo::model::linestring<point>;
using box = bgeo::model::box<point>;

} // namespace prim

struct point : public prim::point
{
  zone zone;

  explicit inline point(class zone zone, double x, double y)
    : prim::point{x, y}, zone{zone}
  {
  }
};

struct linestring : public prim::linestring
{
  zone zone;

  explicit inline linestring(class zone zone) : zone{zone} {}
};

} // namespace routemon::geo::utm::zone_local

BOOST_GEOMETRY_REGISTER_LINESTRING(routemon::geo::utm::zone_local::linestring)

namespace boost::geometry::traits {

namespace {

using zone_local_point = routemon::geo::utm::zone_local::point;

} // namespace

template <>
struct tag<zone_local_point>
{
  using type = point_tag;
};
template <>
struct dimension<zone_local_point> : boost::mpl::int_<2>
{
};
template <>
struct coordinate_type<zone_local_point>
{
  using type = double;
};
template <>
struct coordinate_system<zone_local_point>
{
  using type = routemon::geo::utm::zone_local::cs;
};

template <std::size_t index>
struct access<zone_local_point, index>
{
  static inline auto get(zone_local_point const& p) -> double
  {
    return bgeo::get<index>(
        static_cast<routemon::geo::utm::zone_local::prim::point const&>(p));
  }

  static inline auto set(zone_local_point& p, double v) -> void
  {
    return bgeo::set<index>(
        static_cast<routemon::geo::utm::zone_local::prim::point&>(p), v);
  }
};

} // namespace boost::geometry::traits