FireSTARR
Loading...
Searching...
No Matches
Point.h
1/* SPDX-License-Identifier: AGPL-3.0-or-later */
2#ifndef FS_POINT_H
3#define FS_POINT_H
4#include "stdafx.h"
5namespace fs
6{
10class Point
11{
12public:
18 constexpr Point(const MathSize latitude, const MathSize longitude) noexcept
20 { }
21 ~Point() noexcept = default;
22 Point(const Point& rhs) noexcept = default;
23 Point(Point&& rhs) noexcept = default;
24 Point& operator=(const Point& rhs) noexcept = default;
25 Point& operator=(Point&& rhs) noexcept = default;
30 [[nodiscard]] constexpr MathSize latitude() const noexcept { return latitude_; }
35 [[nodiscard]] constexpr MathSize longitude() const noexcept { return longitude_; }
36
37private:
41 MathSize latitude_;
45 MathSize longitude_;
46};
47}
48template <typename T>
49concept LatLong = requires(const T& p) {
50 { p.latitude() } noexcept -> std::same_as<fs::MathSize>;
51 { p.longitude() } noexcept -> std::same_as<fs::MathSize>;
52};
53template <class T>
54 requires LatLong<T>
55struct std::formatter<T> : std::formatter<string_view>
56{
57 constexpr auto parse(std::format_parse_context& ctx) { return ctx.begin(); }
58 // apple clang didn't work with std::format_context
59 template <class FormatContext>
60 auto format(const T& p, FormatContext& ctx) const
61 {
62 std::string tmp{};
63 std::format_to(
64 std::back_inserter(tmp), "({:f}\u00b0, {:f}\u00b0)", p.latitude(), p.longitude()
65 );
66 return std::formatter<string_view>::format(tmp, ctx);
67 }
68};
69#endif
A geographic location in lat/long coordinates.
Definition Point.h:11
constexpr Point(const MathSize latitude, const MathSize longitude) noexcept
Constructor.
Definition Point.h:18
constexpr MathSize latitude() const noexcept
Latitude (decimal degrees)
Definition Point.h:30
MathSize longitude_
Longitude (decimal degrees)
Definition Point.h:45
MathSize latitude_
Latitude (decimal degrees)
Definition Point.h:41
constexpr MathSize longitude() const noexcept
Longitude (decimal degrees)
Definition Point.h:35
Definition Point.h:49