Program Listing for File rinex_nav_loader.h

Return to documentation for file (interfaces/rinex_nav_loader.h)

#pragma once

#include <filesystem>
#include <map>
#include <string>
#include <vector>

#include "lupnt/core/definitions.h"

namespace lupnt {

  class RinexNavLoader {
  public:
    RinexNavLoader() = default;

    explicit RinexNavLoader(const std::filesystem::path& filepath);

    explicit RinexNavLoader(const std::vector<std::filesystem::path>& filepaths);

    void LoadFile(const std::filesystem::path& filepath);

    const std::vector<std::string>& GetSatellites() const { return sats_; }

    bool HasSatellite(const std::string& sat_id) const;

    void GetPosVelClock(const std::string& sat_id, Real t_tai, Vec6& rv_ecef,
                        Real& clock_corr_s) const;

    Vec6 GetPosVel(const std::string& sat_id, Real t_tai) const;

  private:
    struct NavMessage {
      double epoch_tai = 0.0;
      double af0 = 0.0, af1 = 0.0, af2 = 0.0;
      double crs = 0.0, delta_n = 0.0, m0 = 0.0;
      double cuc = 0.0, ecc = 0.0, cus = 0.0, sqrt_a = 0.0;
      double toe = 0.0, cic = 0.0, omega0 = 0.0, cis = 0.0;
      double i0 = 0.0, crc = 0.0, omega = 0.0, omega_dot = 0.0, idot = 0.0;
      double week = 0.0;
    };

    std::vector<std::string> sats_;
    std::map<std::string, std::vector<NavMessage>> nav_;  // sat_id -> messages (any order)

    void ParseFile(const std::filesystem::path& filepath);

    int FindClosestMessage(const std::string& sat_id, double t_tai) const;
  };

}  // namespace lupnt