.. _program_listing_file_interfaces_lola_dem.h: Program Listing for File lola_dem.h =================================== |exhale_lsh| :ref:`Return to documentation for file ` (``interfaces/lola_dem.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #pragma once #include #include #include #include "lupnt/core/definitions.h" namespace lupnt { struct LolaSite { std::string id; std::string name; double lat_deg; double lon_deg; }; const std::vector& GetLolaSites(); const LolaSite& SelectLolaSite(double lat_deg, double lon_deg); std::string LolaDemUrl(const std::string& site_id); std::filesystem::path DownloadLolaDem(const std::string& site_id); class LunarDem { public: LunarDem() = default; LunarDem(const MatXd& x, const MatXd& y, const MatXd& elev, const LolaSite& site); double GetElevation(double x, double y) const; double GetElevationLatLon(double lat_deg, double lon_deg) const; const MatXd& x() const { return x_; } const MatXd& y() const { return y_; } const MatXd& elevation() const { return elev_; } const LolaSite& site() const { return site_; } int rows() const { return static_cast(elev_.rows()); } int cols() const { return static_cast(elev_.cols()); } double x_min() const { return std::min(x_left_, x_right_); } double x_max() const { return std::max(x_left_, x_right_); } double y_min() const { return std::min(y_top_, y_bottom_); } double y_max() const { return std::max(y_top_, y_bottom_); } double center_x() const { return 0.5 * (x_left_ + x_right_); } double center_y() const { return 0.5 * (y_top_ + y_bottom_); } private: MatXd x_, y_, elev_; LolaSite site_; // Regular-grid parameters cached for fast bilinear lookup. Columns increase in x, // rows increase in y (dy_ is typically negative for a north-up raster). double x0_ = 0.0, y0_ = 0.0; // coordinate of pixel-center (row 0, col 0) double dx_ = 1.0, dy_ = 1.0; // per-column / per-row coordinate step [m] int nx_ = 0, ny_ = 0; double x_left_ = 0.0, x_right_ = 0.0, y_top_ = 0.0, y_bottom_ = 0.0; }; LunarDem LoadLolaDem(double lat_deg, double lon_deg, double half_width_m = 5000.0, double max_res = 20.0, const std::filesystem::path& dem_file = {}); } // namespace lupnt