diff options
| author | Rutger Broekhoff | 2026-09-08 01:36:38 +0200 |
|---|---|---|
| committer | Rutger Broekhoff | 2026-09-08 01:37:34 +0200 |
| commit | 3e8ce840c70ee00925210b96738696d1dc445f8f (patch) | |
| tree | 4eb6b30b1d571daa596394c36e7769f6ee0af956 /server/src/geo/utm_zone_local.cppm | |
| parent | 15bcf23f2e75f9c710eee3753d530ebefc5f78f1 (diff) | |
| download | routemon-3e8ce840c70ee00925210b96738696d1dc445f8f.tar.gz routemon-3e8ce840c70ee00925210b96738696d1dc445f8f.zip | |
UTM projection
Diffstat (limited to 'server/src/geo/utm_zone_local.cppm')
| -rw-r--r-- | server/src/geo/utm_zone_local.cppm | 74 |
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 @@ | |||
| 1 | module; | ||
| 2 | |||
| 3 | #include <boost/geometry.hpp> | ||
| 4 | #include <boost/geometry/geometries/register/linestring.hpp> | ||
| 5 | |||
| 6 | export module routemon:geo.utm.zone_local; | ||
| 7 | |||
| 8 | import :geo; | ||
| 9 | import :geo.utm; | ||
| 10 | |||
| 11 | // Coordinates that are local to some known UTM zone. | ||
| 12 | namespace 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 | |||
| 46 | BOOST_GEOMETRY_REGISTER_LINESTRING(routemon::geo::utm::zone_local::linestring) | ||
| 47 | |||
| 48 | namespace 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 | ||