gps_pvt 0.6.4 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,6 +22,7 @@
22
22
  #include "navigation/QZSS.h"
23
23
  #include "navigation/GLONASS.h"
24
24
  #include "navigation/RINEX.h"
25
+ #include "navigation/RINEX_Clock.h"
25
26
  #include "navigation/SP3.h"
26
27
  #include "navigation/ANTEX.h"
27
28
 
@@ -228,12 +229,10 @@ struct GPS_Ionospheric_UTC_Parameters : public GPS_SpaceNode<FloatT>::Ionospheri
228
229
  %}
229
230
  %extend GPS_Ionospheric_UTC_Parameters {
230
231
  %fragment(SWIG_Traits_frag(FloatT));
231
- %typemap(in,numinputs=0) FloatT values[4] (FloatT temp[4]) %{
232
- $1 = temp;
233
- %}
234
- %typemap(argout) FloatT values[4] {
232
+ %typemap(in,numinputs=0) const FloatT *values[4] (FloatT *temp) "$1 = &temp;"
233
+ %typemap(argout) const FloatT *values[4] {
235
234
  for(int i(0); i < 4; ++i){
236
- %append_output(swig::from($1[i]));
235
+ %append_output(swig::from((*$1)[i]));
237
236
  }
238
237
  }
239
238
  MAKE_ARRAY_INPUT(const FloatT, values, swig::asval);
@@ -245,11 +244,7 @@ struct GPS_Ionospheric_UTC_Parameters : public GPS_SpaceNode<FloatT>::Ionospheri
245
244
  }
246
245
  }
247
246
  %rename("alpha") get_alpha;
248
- void get_alpha(FloatT values[4]) const {
249
- for(int i(0); i < 4; ++i){
250
- values[i] = self->alpha[i];
251
- }
252
- }
247
+ void get_alpha(const FloatT *values[4]) const {*values = self->alpha;}
253
248
  %rename("beta=") set_beta;
254
249
  void set_beta(const FloatT values[4]){
255
250
  for(int i(0); i < 4; ++i){
@@ -257,11 +252,7 @@ struct GPS_Ionospheric_UTC_Parameters : public GPS_SpaceNode<FloatT>::Ionospheri
257
252
  }
258
253
  }
259
254
  %rename("beta") get_beta;
260
- void get_beta(FloatT values[4]) const {
261
- for(int i(0); i < 4; ++i){
262
- values[i] = self->beta[i];
263
- }
264
- }
255
+ void get_beta(const FloatT *values[4]) const {*values = self->beta;}
265
256
  MAKE_ACCESSOR(A1, FloatT);
266
257
  MAKE_ACCESSOR(A0, FloatT);
267
258
  MAKE_ACCESSOR(t_ot, unsigned int);
@@ -1006,6 +997,7 @@ const type &get_ ## name () const {
1006
997
  %inline %{
1007
998
  template <class FloatT>
1008
999
  struct GPS_SolverOptions_Common {
1000
+ virtual ~GPS_SolverOptions_Common() {}
1009
1001
  virtual GPS_Solver_GeneralOptions<FloatT> *cast_general() = 0;
1010
1002
  virtual const GPS_Solver_GeneralOptions<FloatT> *cast_general() const = 0;
1011
1003
  };
@@ -1206,7 +1198,10 @@ struct GPS_RangeCorrector
1206
1198
  if(!res.is_available()){
1207
1199
  static const VALUE key(ID2SYM(rb_intern("relative_property")));
1208
1200
  VALUE hook(rb_hash_lookup(hooks, key));
1209
- if(!NIL_P(hook)){res.impl = this;}
1201
+ if(!NIL_P(hook)){
1202
+ if(!res.impl_xyz){res.impl_xyz = this;}
1203
+ if(!res.impl_t){res.impl_t = this;}
1204
+ }
1210
1205
  }
1211
1206
  #endif
1212
1207
  return res;
@@ -1653,31 +1648,8 @@ template <class FloatT>
1653
1648
  struct RINEX_Observation {};
1654
1649
  }
1655
1650
 
1656
- %extend SP3 {
1657
- %typemap(in,numinputs=0) int count[ANY] (int temp[$1_dim0]) "$1 = temp;"
1658
- %typemap(argout) int count[ANY] {
1659
- for(int i(0); i < $1_dim0; ++i){
1660
- %append_output(SWIG_From(int)($1[i]));
1661
- }
1662
- }
1663
- void satellites(int count[SP3::SYS_SYSTEMS]) const {
1664
- typename SP3_Product<FloatT>::satellite_count_t x(self->satellite_count());
1665
- count[SP3<FloatT>::SYS_GPS] = x.gps;
1666
- count[SP3<FloatT>::SYS_SBAS] = x.sbas;
1667
- count[SP3<FloatT>::SYS_QZSS] = x.qzss;
1668
- count[SP3<FloatT>::SYS_GLONASS] = x.glonass;
1669
- count[SP3<FloatT>::SYS_GALILEO] = x.galileo;
1670
- count[SP3<FloatT>::SYS_BEIDOU] = x.beidou;
1671
- }
1672
-
1673
- }
1674
1651
  %inline {
1675
- template <class FloatT>
1676
- struct SP3 : public SP3_Product<FloatT> {
1677
- int read(const char *fname) {
1678
- std::fstream fin(fname, std::ios::in | std::ios::binary);
1679
- return SP3_Reader<FloatT>::read_all(fin, *this);
1680
- }
1652
+ struct PushableData {
1681
1653
  enum system_t {
1682
1654
  SYS_GPS,
1683
1655
  SYS_SBAS,
@@ -1687,20 +1659,21 @@ struct SP3 : public SP3_Product<FloatT> {
1687
1659
  SYS_BEIDOU,
1688
1660
  SYS_SYSTEMS,
1689
1661
  };
1690
- bool push(GPS_Solver<FloatT> &solver, const system_t &sys) const {
1662
+ template <class DataT, class FloatT>
1663
+ static bool push(DataT &data, GPS_Solver<FloatT> &solver, const system_t &sys){
1691
1664
  switch(sys){
1692
1665
  case SYS_GPS:
1693
- return SP3_Product<FloatT>::push(
1694
- solver.gps.ephemeris_proxy.gps, SP3_Product<FloatT>::SYSTEM_GPS);
1666
+ return data.push(
1667
+ solver.gps.ephemeris_proxy.gps, DataT::SYSTEM_GPS);
1695
1668
  case SYS_SBAS:
1696
- return SP3_Product<FloatT>::push(
1697
- solver.sbas.solver.satellites, SP3_Product<FloatT>::SYSTEM_SBAS);
1669
+ return data.push(
1670
+ solver.sbas.solver.satellites, DataT::SYSTEM_SBAS);
1698
1671
  case SYS_QZSS:
1699
- return SP3_Product<FloatT>::push(
1700
- solver.gps.ephemeris_proxy.qzss, SP3_Product<FloatT>::SYSTEM_QZSS);
1672
+ return data.push(
1673
+ solver.gps.ephemeris_proxy.qzss, DataT::SYSTEM_QZSS);
1701
1674
  case SYS_GLONASS:
1702
- return SP3_Product<FloatT>::push(
1703
- solver.glonass.solver.satellites, SP3_Product<FloatT>::SYSTEM_GLONASS);
1675
+ return data.push(
1676
+ solver.glonass.solver.satellites, DataT::SYSTEM_GLONASS);
1704
1677
  case SYS_GALILEO:
1705
1678
  case SYS_BEIDOU:
1706
1679
  default:
@@ -1708,7 +1681,8 @@ struct SP3 : public SP3_Product<FloatT> {
1708
1681
  }
1709
1682
  return false;
1710
1683
  }
1711
- bool push(GPS_Solver<FloatT> &solver) const {
1684
+ template <class DataT, class FloatT>
1685
+ static bool push(DataT &data, GPS_Solver<FloatT> &solver){
1712
1686
  system_t target[] = {
1713
1687
  SYS_GPS,
1714
1688
  SYS_SBAS,
@@ -1718,10 +1692,39 @@ struct SP3 : public SP3_Product<FloatT> {
1718
1692
  //SYS_BEIDOU,
1719
1693
  };
1720
1694
  for(std::size_t i(0); i < sizeof(target) / sizeof(target[0]); ++i){
1721
- if(!push(solver, target[i])){return false;}
1695
+ if(!push(data, solver, target[i])){return false;}
1722
1696
  }
1723
1697
  return true;
1724
1698
  }
1699
+ };
1700
+ }
1701
+
1702
+ %extend SP3 {
1703
+ %typemap(out) typename SP3_Product<FloatT>::satellite_count_t {
1704
+ %append_output(SWIG_From(int)($1.gps));
1705
+ %append_output(SWIG_From(int)($1.sbas));
1706
+ %append_output(SWIG_From(int)($1.qzss));
1707
+ %append_output(SWIG_From(int)($1.glonass));
1708
+ %append_output(SWIG_From(int)($1.galileo));
1709
+ %append_output(SWIG_From(int)($1.beidou));
1710
+ }
1711
+ }
1712
+ %inline {
1713
+ template <class FloatT>
1714
+ struct SP3 : public SP3_Product<FloatT>, PushableData {
1715
+ int read(const char *fname) {
1716
+ std::fstream fin(fname, std::ios::in | std::ios::binary);
1717
+ return SP3_Reader<FloatT>::read_all(fin, *this);
1718
+ }
1719
+ typename SP3_Product<FloatT>::satellite_count_t satellites() const {
1720
+ return SP3_Product<FloatT>::satellite_count();
1721
+ }
1722
+ bool push(GPS_Solver<FloatT> &solver, const PushableData::system_t &sys) const {
1723
+ return PushableData::push((SP3_Product<FloatT> &)*this, solver, sys);
1724
+ }
1725
+ bool push(GPS_Solver<FloatT> &solver) const {
1726
+ return PushableData::push((SP3_Product<FloatT> &)*this, solver);
1727
+ }
1725
1728
  System_XYZ<FloatT, WGS84> position(
1726
1729
  const int &sat_id, const GPS_Time<FloatT> &t) const {
1727
1730
  return SP3_Product<FloatT>::select(sat_id, t).position(t);
@@ -1748,6 +1751,46 @@ struct SP3 : public SP3_Product<FloatT> {
1748
1751
  };
1749
1752
  }
1750
1753
 
1754
+ %extend RINEX_Clock {
1755
+ %typemap(out) typename RINEX_CLK<FloatT>::satellites_t::count_t {
1756
+ %append_output(SWIG_From(int)($1.gps));
1757
+ %append_output(SWIG_From(int)($1.sbas));
1758
+ %append_output(SWIG_From(int)($1.qzss));
1759
+ %append_output(SWIG_From(int)($1.glonass));
1760
+ %append_output(SWIG_From(int)($1.galileo));
1761
+ %append_output(SWIG_From(int)($1.beidou));
1762
+ }
1763
+ }
1764
+ %inline {
1765
+ template <class FloatT>
1766
+ struct RINEX_Clock : public RINEX_CLK<FloatT>::satellites_t, PushableData {
1767
+ typedef typename RINEX_CLK<FloatT>::satellites_t super_t;
1768
+ int read(const char *fname) {
1769
+ std::fstream fin(fname, std::ios::in | std::ios::binary);
1770
+ return RINEX_CLK_Reader<FloatT>::read_all(fin, *this);
1771
+ }
1772
+ typename RINEX_CLK<FloatT>::satellites_t::count_t satellites() const {
1773
+ return RINEX_CLK<FloatT>::satellites_t::count();
1774
+ }
1775
+ bool push(GPS_Solver<FloatT> &solver, const PushableData::system_t &sys) const {
1776
+ return PushableData::push((typename RINEX_CLK<FloatT>::satellites_t &)*this, solver, sys);
1777
+ }
1778
+ bool push(GPS_Solver<FloatT> &solver) const {
1779
+ return PushableData::push((typename RINEX_CLK<FloatT>::satellites_t &)*this, solver);
1780
+ }
1781
+ FloatT clock_error(const int &sat_id, const GPS_Time<FloatT> &t) const {
1782
+ typename super_t::buf_t::const_iterator it(this->buf.find(sat_id));
1783
+ if(it == this->buf.end()){return super_t::sat_t::unavailable().clock_error(t);}
1784
+ return it->second.clock_error(t);
1785
+ }
1786
+ FloatT clock_error_dot(const int &sat_id, const GPS_Time<FloatT> &t) const {
1787
+ typename super_t::buf_t::const_iterator it(this->buf.find(sat_id));
1788
+ if(it == this->buf.end()){return super_t::sat_t::unavailable().clock_error(t);}
1789
+ return it->second.clock_error_dot(t);
1790
+ }
1791
+ };
1792
+ }
1793
+
1751
1794
  #undef MAKE_ACCESSOR
1752
1795
  #undef MAKE_VECTOR2ARRAY
1753
1796
  #undef MAKE_ARRAY_INPUT
@@ -1776,6 +1819,7 @@ struct SP3 : public SP3_Product<FloatT> {
1776
1819
 
1777
1820
  %template(RINEX_Observation) RINEX_Observation<type>;
1778
1821
  %template(SP3) SP3<type>;
1822
+ %template(RINEX_Clock) RINEX_Clock<type>;
1779
1823
  %enddef
1780
1824
 
1781
1825
  CONCRETIZE(double);
@@ -592,7 +592,6 @@ struct MatrixUtil {
592
592
  }
593
593
  static VALUE read(
594
594
  const VALUE &v, const unsigned int &row = 0, const unsigned int &column = 0) {
595
- int state;
596
595
  VALUE values[3] = {v, UINT2NUM(row), UINT2NUM(column)};
597
596
  return funcall_throw_if_error(run, reinterpret_cast<VALUE>(values));
598
597
  }
@@ -865,7 +864,7 @@ struct MatrixUtil {
865
864
  static const ID with_index[] = {
866
865
  rb_intern("map_with_index"), rb_intern("map_with_index!"),
867
866
  rb_intern("collect_with_index"), rb_intern("collect_with_index!")};
868
- for(int i(0); i < sizeof(with_index) / sizeof(with_index[0]); ++i){
867
+ for(std::size_t i(0); i < sizeof(with_index) / sizeof(with_index[0]); ++i){
869
868
  if(id_callee == with_index[i]){
870
869
  return matrix_yield_get_with_index;
871
870
  }
@@ -651,5 +651,21 @@ class Receiver
651
651
  raise "Format error! (Not ANTEX) #{src}" unless applied_items >= 0
652
652
  $stderr.puts "SP3 correction with ANTEX file (%s): %d items have been processed."%[src, applied_items]
653
653
  end
654
+
655
+ def attach_rinex_clk(src)
656
+ fname = Util::get_txt(src)
657
+ @clk ||= GPS::RINEX_Clock::new
658
+ read_items = @clk.read(fname)
659
+ raise "Format error! (Not RINEX clock) #{src}" if read_items < 0
660
+ $stderr.puts "Read RINEX clock file (%s): %d items."%[src, read_items]
661
+ sats = @clk.satellites
662
+ @clk.class.constants.each{|sys|
663
+ next unless /^SYS_(?!SYSTEMS)(.*)/ =~ sys.to_s
664
+ idx, sys_name = [@clk.class.const_get(sys), $1]
665
+ next unless sats[idx] > 0
666
+ next unless @clk.push(@solver, idx)
667
+ $stderr.puts "Change clock error source of #{sys_name} to RINEX clock"
668
+ }
669
+ end
654
670
  end
655
671
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GPS_PVT
4
- VERSION = "0.6.4"
4
+ VERSION = "0.7.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gps_pvt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - fenrir(M.Naruoka)
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-19 00:00:00.000000000 Z
11
+ date: 2022-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -78,6 +78,7 @@ files:
78
78
  - ext/ninja-scan-light/tool/navigation/NTCM.h
79
79
  - ext/ninja-scan-light/tool/navigation/QZSS.h
80
80
  - ext/ninja-scan-light/tool/navigation/RINEX.h
81
+ - ext/ninja-scan-light/tool/navigation/RINEX_Clock.h
81
82
  - ext/ninja-scan-light/tool/navigation/SBAS.h
82
83
  - ext/ninja-scan-light/tool/navigation/SBAS_Solver.h
83
84
  - ext/ninja-scan-light/tool/navigation/SP3.h