From 00a2bce0e820560cb178f6c7ccab7399fdbadc2c Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Tue, 3 Oct 2023 11:00:33 -0600 Subject: [PATCH] fix(example): `latitude` and `longitude` fixed to include `0` for `N` and `E` respectively --- example/include/geographic.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/example/include/geographic.h b/example/include/geographic.h index c422fa76..b704dd24 100644 --- a/example/include/geographic.h +++ b/example/include/geographic.h @@ -79,7 +79,7 @@ using longitude = mp_units::quantity_point std::basic_ostream& operator<<(std::basic_ostream& os, const latitude& lat) { - if (is_gt_zero(lat)) + if (is_gteq_zero(lat)) return os << lat.quantity_from_origin() << " N"; else return os << -lat.quantity_from_origin() << " S"; @@ -88,7 +88,7 @@ std::basic_ostream& operator<<(std::basic_ostream& template std::basic_ostream& operator<<(std::basic_ostream& os, const longitude& lon) { - if (is_gt_zero(lon)) + if (is_gteq_zero(lon)) return os << lon.quantity_from_origin() << " E"; else return os << -lon.quantity_from_origin() << " W"; @@ -138,8 +138,8 @@ struct MP_UNITS_STD_FMT::formatter> : auto format(geographic::latitude lat, FormatContext& ctx) { formatter::quantity_type>::format( - is_gt_zero(lat) ? lat.quantity_from(geographic::equator) : -lat.quantity_from(geographic::equator), ctx); - MP_UNITS_STD_FMT::format_to(ctx.out(), "{}", is_gt_zero(lat) ? " N" : "S"); + is_gteq_zero(lat) ? lat.quantity_from(geographic::equator) : -lat.quantity_from(geographic::equator), ctx); + MP_UNITS_STD_FMT::format_to(ctx.out(), "{}", is_gteq_zero(lat) ? " N" : "S"); return ctx.out(); } }; @@ -151,9 +151,10 @@ struct MP_UNITS_STD_FMT::formatter> : auto format(geographic::longitude lon, FormatContext& ctx) { formatter::quantity_type>::format( - is_gt_zero(lon) ? lon.quantity_from(geographic::prime_meridian) : -lon.quantity_from(geographic::prime_meridian), + is_gteq_zero(lon) ? lon.quantity_from(geographic::prime_meridian) + : -lon.quantity_from(geographic::prime_meridian), ctx); - MP_UNITS_STD_FMT::format_to(ctx.out(), "{}", is_gt_zero(lon) ? " E" : " W"); + MP_UNITS_STD_FMT::format_to(ctx.out(), "{}", is_gteq_zero(lon) ? " E" : " W"); return ctx.out(); } };