summaryrefslogtreecommitdiffstats
path: root/server/src/geo/utm_zone_local.cppm
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/geo/utm_zone_local.cppm')
-rw-r--r--server/src/geo/utm_zone_local.cppm74
1 files changed, 74 insertions, 0 deletions
diff --git a/server/src/geo/utm_zone_local.cppm b/server/src/geo/utm_zone_local.cppm
new file mode 100644
index 0000000..98a1344
--- /dev/null
+++ b/server/src/geo/utm_zone_local.cppm
@@ -0,0 +1,74 @@
1module;
2
3#include <boost/geometry.hpp>
4#include <boost/geometry/geometries/register/linestring.hpp>
5
6export module routemon:geo.utm.zone_local;
7
8import :geo;
9import :geo.utm;
10
11// Coordinates that are local to some known UTM zone.
12namespace routemon::geo::utm::zone_local {
13
14 using cs = bgeo::cs::cartesian;
15
16 namespace prim {
17
18 using point = bgeo::model::d2::point_xy<double>;
19 using linestring = bgeo::model::linestring<point>;
20 using box = bgeo::model::box<point>;
21
22 } // namespace prim
23
24 struct point : public prim::point
25 {
26 zone zone;
27
28 explicit point(class zone zone, double x, double y)
29 : prim::point{x, y}, zone{zone}
30 {
31 }
32 };
33
34 struct linestring : public prim::linestring
35 {
36 zone zone;
37
38 explicit linestring(class zone zone)
39 : zone{zone}
40 {
41 }
42 };
43
44} // namespace routemon::geo::utm::zone_local
45
46BOOST_GEOMETRY_REGISTER_LINESTRING(routemon::geo::utm::zone_local::linestring)
47
48namespace boost::geometry::traits {
49
50 namespace {
51
52 using zone_local_point = routemon::geo::utm::zone_local::point;
53
54 } // namespace <anonymous>
55
56 template<> struct tag<zone_local_point> { using type = point_tag; };
57 template<> struct dimension<zone_local_point> : boost::mpl::int_<2> {};
58 template<> struct coordinate_type<zone_local_point> { using type = double; };
59 template<> struct coordinate_system<zone_local_point> { using type = routemon::geo::utm::zone_local::cs; };
60
61 template<std::size_t index>
62 struct access<zone_local_point, index> {
63 static inline auto get(zone_local_point const& p) -> double
64 {
65 return bgeo::get<index>(static_cast<routemon::geo::utm::zone_local::prim::point const&>(p));
66 }
67
68 static inline auto set(zone_local_point& p, double v) -> void
69 {
70 return bgeo::set<index>(static_cast<routemon::geo::utm::zone_local::prim::point&>(p), v);
71 }
72 };
73
74} // namespace boost::geometry::traits