Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions src/cpp/fs/Environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<MathSize>::min();
Expand Down Expand Up @@ -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);
Expand Down
13 changes: 3 additions & 10 deletions src/cpp/fs/Grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,7 @@ std::optional<FullCoordinates> 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);
Expand All @@ -415,9 +409,8 @@ std::optional<FullCoordinates> 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,
Expand Down
10 changes: 2 additions & 8 deletions src/cpp/fs/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -853,13 +853,7 @@ map<DurationSize, shared_ptr<ProbabilityMap>> Model::runIterations(
static_assert(std::numeric_limits<size_t>::digits10 >= precision);
const auto lat = static_cast<size_t>(abs(start_point.latitude()) * pow(10, precision));
const auto lon = static_cast<size_t>(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<size_t>(start_day);
Expand Down
21 changes: 21 additions & 0 deletions src/cpp/fs/Point.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,25 @@ class Point
MathSize longitude_;
};
}
template <typename T>
concept LatLong = requires(const T& p) {
{ p.latitude() } noexcept -> std::same_as<fs::MathSize>;
{ p.longitude() } noexcept -> std::same_as<fs::MathSize>;
};
template <class T>
requires LatLong<T>
struct std::formatter<T> : std::formatter<string_view>
{
constexpr auto parse(std::format_parse_context& ctx) { return ctx.begin(); }
// apple clang didn't work with std::format_context
template <class FormatContext>
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<string_view>::format(tmp, ctx);
}
};
#endif
5 changes: 2 additions & 3 deletions src/cpp/fs/SimpleFBP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,9 @@ vector<int> 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
);
Expand Down
10 changes: 4 additions & 6 deletions src/cpp/fs/projection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ std::optional<FullCoordinates> 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,
Expand Down Expand Up @@ -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,
Expand Down
Loading