diff options
Diffstat (limited to 'server/src/gpx.cpp')
| -rw-r--r-- | server/src/gpx.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/server/src/gpx.cpp b/server/src/gpx.cpp index 078248f..2193e6a 100644 --- a/server/src/gpx.cpp +++ b/server/src/gpx.cpp | |||
| @@ -22,7 +22,7 @@ auto qname(std::string_view local) -> xml::qname_view | |||
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | auto parse_wpt(xml::executor_ref e, xml::attribute_view attrs) | 24 | auto parse_wpt(xml::executor_ref e, xml::attribute_view attrs) |
| 25 | -> xml::parser<geo::point> | 25 | -> xml::parser<geo::utm::zonable_wgs84_point> |
| 26 | { | 26 | { |
| 27 | auto parse_xml_double = [](std::string_view sv) -> std::optional<double> | 27 | auto parse_xml_double = [](std::string_view sv) -> std::optional<double> |
| 28 | { return util::parse_double(sv, std::chars_format::fixed); }; | 28 | { return util::parse_double(sv, std::chars_format::fixed); }; |
| @@ -43,8 +43,12 @@ auto parse_wpt(xml::executor_ref e, xml::attribute_view attrs) | |||
| 43 | throw std::runtime_error{ | 43 | throw std::runtime_error{ |
| 44 | "expected valid latitude and longitude for waypoint" | 44 | "expected valid latitude and longitude for waypoint" |
| 45 | }; | 45 | }; |
| 46 | auto mp = geo::utm::zonable_wgs84_point::from( | ||
| 47 | geo::wgs84::normalized_point{geo::wgs84::from_lat_lon(*mlat, *mlon)}); | ||
| 48 | if (!mp) | ||
| 49 | throw std::runtime_error{"expected waypoint to be within UTM range"}; | ||
| 46 | co_await xml::ignore_contents(e); | 50 | co_await xml::ignore_contents(e); |
| 47 | co_return geo::point{*mlon, *mlat}; | 51 | co_return *mp; |
| 48 | } | 52 | } |
| 49 | 53 | ||
| 50 | auto parse_trkseg(xml::executor_ref e, xml::attribute_view) | 54 | auto parse_trkseg(xml::executor_ref e, xml::attribute_view) |
| @@ -121,7 +125,7 @@ auto parse_metadata(xml::executor_ref e, xml::attribute_view) | |||
| 121 | } | 125 | } |
| 122 | 126 | ||
| 123 | auto parse_wpt(xml::executor_ref e, xml::attribute_view attrs) | 127 | auto parse_wpt(xml::executor_ref e, xml::attribute_view attrs) |
| 124 | -> xml::parser<geo::point> | 128 | -> xml::parser<geo::utm::zonable_wgs84_point> |
| 125 | { | 129 | { |
| 126 | auto parse_xml_double = [](std::string_view sv) -> std::optional<double> | 130 | auto parse_xml_double = [](std::string_view sv) -> std::optional<double> |
| 127 | { return util::parse_double(sv, std::chars_format::fixed); }; | 131 | { return util::parse_double(sv, std::chars_format::fixed); }; |
| @@ -142,8 +146,12 @@ auto parse_wpt(xml::executor_ref e, xml::attribute_view attrs) | |||
| 142 | throw std::runtime_error{ | 146 | throw std::runtime_error{ |
| 143 | "expected valid latitude and longitude for waypoint" | 147 | "expected valid latitude and longitude for waypoint" |
| 144 | }; | 148 | }; |
| 149 | auto mp = geo::utm::zonable_wgs84_point::from( | ||
| 150 | geo::wgs84::normalized_point{geo::wgs84::from_lat_lon(*mlat, *mlon)}); | ||
| 151 | if (!mp) | ||
| 152 | throw std::runtime_error{"expected waypoint to be within UTM range"}; | ||
| 145 | co_await xml::ignore_contents(e); | 153 | co_await xml::ignore_contents(e); |
| 146 | co_return geo::point{*mlon, *mlat}; | 154 | co_return *mp; |
| 147 | } | 155 | } |
| 148 | 156 | ||
| 149 | auto parse_trkseg(xml::executor_ref e, xml::attribute_view) | 157 | auto parse_trkseg(xml::executor_ref e, xml::attribute_view) |