diff --git a/src/cpp/fs/Environment.cpp b/src/cpp/fs/Environment.cpp index 159e787417..e1fc1b0ef3 100644 --- a/src/cpp/fs/Environment.cpp +++ b/src/cpp/fs/Environment.cpp @@ -59,7 +59,7 @@ Environment Environment::loadEnvironment( const YearSize year ) { - logging::note("Using ignition point ({:f}, {:f})", point.latitude(), point.longitude()); + logging::note("Using ignition point {}", point); logging::info("Running using inputs directory '{:s}'", string(path)); auto rasters = find_rasters(path, year); auto best_score = numeric_limits::min(); @@ -142,18 +142,8 @@ Environment Environment::loadEnvironment( logging::note("Loading info for fuel {:s}", best_fuel); env_info = EnvironmentInfo::loadInfo(best_fuel, best_elevation); } - logging::check_fatal( - nullptr == env_info, - "Could not find an environment to use for ({:f}, {:f})", - point.latitude(), - point.longitude() - ); - logging::debug( - "Best match for ({:f}, {:f}) has projection '{:s}'", - point.latitude(), - point.longitude(), - env_info->proj4() - ); + logging::check_fatal(nullptr == env_info, "Could not find an environment to use for {}", point); + logging::debug("Best match for {} has projection '{:s}'", point, env_info->proj4()); logging::note("Projection is {:s}", env_info->proj4()); // envInfo should get deleted automatically because it uses unique_ptr return env_info->load(point); diff --git a/src/cpp/fs/Grid.cpp b/src/cpp/fs/Grid.cpp index 70176823f2..c5885e0c28 100644 --- a/src/cpp/fs/Grid.cpp +++ b/src/cpp/fs/Grid.cpp @@ -398,13 +398,7 @@ std::optional GridBase::findFullCoordinates(const Point& point, XYPos mid_bottom{x_mid, y_bottom}; XYPos mid_top{x_mid, y_top}; const auto xy = from_lat_long(this->proj4_, point); - logging::debug( - "Coordinates ({:f}, {:f}) converted to ({:f}, {:f})", - point.latitude(), - point.longitude(), - xy.x.value, - xy.y.value - ); + logging::debug("Coordinates {} converted to ({:f}, {:f})", point, xy.x.value, xy.y.value); auto south = to_lat_long(proj4_, mid_bottom); auto north = to_lat_long(proj4_, mid_top); auto grid_south = from_lat_long(this->proj4_, south); @@ -415,9 +409,8 @@ std::optional GridBase::findFullCoordinates(const Point& point, if (abs(deviation) > MAX_DEVIATION) { logging::note( - "Due north is not the top of the raster for ({:f}, {:f}) with proj4 '{:s}' - {:f} vs {:f} gives deviation of {:f} degrees which exceeds maximum of {:f} degrees", - point.latitude(), - point.longitude(), + "Due north is not the top of the raster for {} with proj4 '{:s}' - {:f} vs {:f} gives deviation of {:f} degrees which exceeds maximum of {:f} degrees", + point, this->proj4_, grid_north.x.value, grid_south.x.value, diff --git a/src/cpp/fs/Model.cpp b/src/cpp/fs/Model.cpp index 88323c605e..b9f4992373 100644 --- a/src/cpp/fs/Model.cpp +++ b/src/cpp/fs/Model.cpp @@ -37,7 +37,7 @@ Model::Model( active_simulations_still_required_(settings.minimum_active_simulation_count), latitude_(start_point.latitude()), longitude_(start_point.longitude()) { - logging::debug("Calculating for ({:f}, {:f})", start_point.latitude(), start_point.longitude()); + logging::debug("Calculating for {}", start_point); const auto nd_for_point = calculate_nd_ref_for_point(env->elevation(), start_point); for (auto day = 0; day < MAX_DAYS; ++day) { @@ -853,13 +853,7 @@ map> Model::runIterations( static_assert(std::numeric_limits::digits10 >= precision); const auto lat = static_cast(abs(start_point.latitude()) * pow(10, precision)); const auto lon = static_cast(abs(start_point.longitude()) * pow(10, precision)); - logging::debug( - "lat/long ({:f}, {:f}) converted to ({:d}, {:d})", - start_point.latitude(), - start_point.longitude(), - lat, - lon - ); + logging::debug("lat/long {} converted to ({:d}, {:d})", start_point, lat, lon); const size_t base_salt = settings.salt; auto make_seed = [&](const char* name, const size_t salt) { const auto d = static_cast(start_day); diff --git a/src/cpp/fs/Point.h b/src/cpp/fs/Point.h index 88fc2195fc..25e1ff807f 100644 --- a/src/cpp/fs/Point.h +++ b/src/cpp/fs/Point.h @@ -45,4 +45,25 @@ class Point MathSize longitude_; }; } +template +concept LatLong = requires(const T& p) { + { p.latitude() } noexcept -> std::same_as; + { p.longitude() } noexcept -> std::same_as; +}; +template + requires LatLong +struct std::formatter : std::formatter +{ + constexpr auto parse(std::format_parse_context& ctx) { return ctx.begin(); } + // apple clang didn't work with std::format_context + template + auto format(const T& p, FormatContext& ctx) const + { + std::string tmp{}; + std::format_to( + std::back_inserter(tmp), "({:f}\u00b0, {:f}\u00b0)", p.latitude(), p.longitude() + ); + return std::formatter::format(tmp, ctx); + } +}; #endif diff --git a/src/cpp/fs/SimpleFBP.cpp b/src/cpp/fs/SimpleFBP.cpp index 78f31bbc3d..b2f3b4bb40 100644 --- a/src/cpp/fs/SimpleFBP.cpp +++ b/src/cpp/fs/SimpleFBP.cpp @@ -532,10 +532,9 @@ vector find_nd_values() const auto nd_ref = calculate_nd_ref_for_point(elevation, pt); nd_ref_values.emplace(nd_ref); logging::verbose( - "now have {:d} values for nd: {:g}, {:g}, {:g} gives nd_ref {:d}", + "now have {:d} values for nd: {}, {:g} gives nd_ref {:d}", nd_ref_values.size(), - latitude, - longitude, + pt, elevation, nd_ref ); diff --git a/src/cpp/fs/projection.cpp b/src/cpp/fs/projection.cpp index 2a0993e7dd..7192f7a134 100644 --- a/src/cpp/fs/projection.cpp +++ b/src/cpp/fs/projection.cpp @@ -49,9 +49,8 @@ std::optional to_proj4( *y = b.enu.n; c = proj_trans(P, PJ_INV, b); cout << std::format( - "longitude: {:f}, latitude: {:f} => easting: {:.3f}, northing: {:.3f} => x: {:.3f}, y: {:.3f} => longitude: {:g}, latitude: {:g}\n", - point.longitude(), - point.latitude(), + "{} => easting: {:.3f}, northing: {:.3f} => x: {:.3f}, y: {:.3f} => longitude: {:g}, latitude: {:g}\n", + point, b.enu.e, b.enu.n, b.xy.x, @@ -113,9 +112,8 @@ fs::XYPos from_lat_long(const string_view proj4, const fs::Point& point) // #ifdef DEBUG_PROJ PJ_COORD c = proj_trans(P, PJ_INV, b); fs::logging::verbose( - "longitude: {:f}, latitude: {:f} => easting: {:.3f}, northing: {:.3f} => x: {:.3f}, y: {:.3f} => longitude: {:g}, latitude: {:g}", - point.longitude(), - point.latitude(), + "{} => easting: {:.3f}, northing: {:.3f} => x: {:.3f}, y: {:.3f} => longitude: {:g}, latitude: {:g}", + point, b.enu.e, b.enu.n, b.xy.x,