From a40e87344de0892b5241f83d82aff9073f8f990b Mon Sep 17 00:00:00 2001 From: fenrir Date: Thu, 28 Mar 2024 23:52:01 +0900 Subject: [PATCH] Remove duplicated functions resulted from SWIG update --- lib/gps_pvt/receiver/extension.rb | 73 ------------------------------- lib/gps_pvt/rtcm3.rb | 8 ++-- lib/gps_pvt/supl.rb | 6 +-- 3 files changed, 7 insertions(+), 80 deletions(-) diff --git a/lib/gps_pvt/receiver/extension.rb b/lib/gps_pvt/receiver/extension.rb index 5da4435..bb63e9f 100644 --- a/lib/gps_pvt/receiver/extension.rb +++ b/lib/gps_pvt/receiver/extension.rb @@ -60,79 +60,6 @@ def attach_online_ephemeris(uri_template = [nil]) module GPS -# These ephemeris helper functions will be removed -# when native functions are available in GPS.i -class Ephemeris - URA_TABLE = [ - 2.40, 3.40, 4.85, 6.85, 9.65, 13.65, 24.00, 48.00, - 96.00, 192.00, 384.00, 768.00, 1536.00, 3072.00, 6144.00] - def URA_index=(idx) - send(:URA=, (idx >= URA_TABLE.size) ? (URA_TABLE[-1] * 2) : (idx < 0 ? -1 : URA_TABLE[idx])) - end - def URA_index - ura = send(:URA) - (ura < 0) ? -1 : URA_TABLE.find_index{|v| ura <= v} - end - proc{ - orig = instance_method(:fit_interval=) - define_method(:fit_interval=){|args| - args = case args - when Array - flag, iodc, sys = args - hr = case (sys ||= :GPS) - when :GPS, :gps - (flag == 0) ? 4 : case iodc - when 240..247; 8 - when 248..255, 496; 14 - when 497..503; 26 - when 504..510; 50 - when 511, 752..756; 74 - when 757..763; 98 - when 764..767, 1088..1010; 122 - when 1011..1020; 146 - else; 6 - end - when :QZSS, :qzss - raise unless flag == 0 # TODO how to treat fit_interval > 2 hrs - 2 - else; raise - end - hr * 60 * 60 - else - args - end - orig.bind(self).call(args) - } - }.call -end -class Ephemeris_SBAS - URA_TABLE = [ # Table 2-3 in DO-229E - 2.0, 2.8, 4.0, 5.7, 8.0, 11.3, 16.0, 32.0, - 64.0, 128.0, 256.0, 512.0, 1024.0, 2048.0, 4096.0] - def URA_index=(idx) - send(:URA=, (idx >= URA_TABLE.size) ? (URA_TABLE[-1] * 2) : (idx < 0 ? -1 : URA_TABLE[idx])) - end - def URA_index - ura = send(:URA) - (ura < 0) ? -1 : URA_TABLE.find_index{|v| ura <= v} - end -end -class Ephemeris_GLONASS - F_T_TABLE = [ # Table 4.4 in ICD 5.1 - 1, 2, 2.5, 4, 5, 7, 10, 12, 14, 16, 32, 64, 128, 256, 512, 1024] - def F_T_index=(idx) - send(:F_T=, (idx >= F_T_TABLE.size) ? (F_T_TABLE[-1] * 2) : (idx < 0 ? -1 : F_T_TABLE[idx])) - end - def F_T_index - f_t = send(:F_T) - (f_t < 0) ? -1 : F_T_TABLE.find_index{|v| f_t <= v} - end - def NA - # based on TimeProperties::date2raw - self.day_of_year + [1, 367, 732, 1097][(self.year - 1996) % 4] - end -end - [ Ionospheric_UTC_Parameters, Ephemeris, Ephemeris_SBAS, Ephemeris_GLONASS, diff --git a/lib/gps_pvt/rtcm3.rb b/lib/gps_pvt/rtcm3.rb index 7ff9057..2a4b3b8 100644 --- a/lib/gps_pvt/rtcm3.rb +++ b/lib/gps_pvt/rtcm3.rb @@ -132,7 +132,7 @@ def message_number 103 => 1, 104 => 1, 105 => 1, - 106 => [2, proc{|v| [0, 30, 45, 60][v] * 60}], # [s] + 106 => 2, 107 => [12, proc{|v| hh, mm, ss = [v >> 7, (v & 0x7E) >> 1, (v & 0x1) > 0 ? 30 : 0] hh * 3600 + mm * 60 + ss # [sec] @@ -314,7 +314,7 @@ module GPS_Ephemeris def params # TODO WN is truncated to 0-1023 res = Hash[*(KEY2IDX.collect{|k, i| [k, self[i][0]]}.flatten(1))] - res[:fit_interval] = [self[29][0], res[:iodc]] + res[:fit_interval] = (self[29][0] != 0) res end end @@ -334,7 +334,7 @@ def params # TODO insufficient: :n => ?(String4); extra: :P3 # TODO generate time with t_b, N_T, NA, N_4 # TODO GPS.i is required to modify to generate EPhemeris_with_GPS_Time - k_i = {:svid => 1, :freq_ch => 2, :P1 => 5, :t_k => 6, :B_n => 7, :P2 => 8, :t_b => 9, + k_i = {:svid => 1, :freq_ch => 2, :P1_index => 5, :t_k => 6, :B_n => 7, :P2 => 8, :t_b => 9, :xn_dot => 10, :xn => 11, :xn_ddot => 12, :yn_dot => 13, :yn => 14, :yn_ddot => 15, :zn_dot => 16, :zn => 17, :zn_ddot => 18, @@ -362,7 +362,7 @@ module QZSS_Ephemeris def params # TODO PRN = svid + 192, WN is truncated to 0-1023 res = Hash[*(KEY2IDX.collect{|k, i| [k, self[i][0]]}.flatten(1))] - res[:fit_interval] = [self[29][0], res[:iodc], :QZSS] + res[:fit_interval] = (self[29][0] != 0) res end end diff --git a/lib/gps_pvt/supl.rb b/lib/gps_pvt/supl.rb index 6bdd375..c0e1fef 100644 --- a/lib/gps_pvt/supl.rb +++ b/lib/gps_pvt/supl.rb @@ -353,7 +353,7 @@ def attach_rrlp(msg) eph.WN -= 1 end eph.iode = eph.iodc & 0xFF - eph.fit_interval = [eph_src[:ephemFitFlag], eph.iodc] + eph.fit_interval = (eph_src[:ephemFitFlag] != 0) eph } } @@ -403,7 +403,7 @@ def attach_rrlp(msg) :zn => [:Z, Rational(1000, 1 << 11)], :zn_dot => [:Zdot, Rational(1000, 1 << 20)], :zn_ddot => [:Zdotdot, Rational(1000, 1 << 30)], :tau_n => [:Tau, Rational(1, 1 << 30)], :gamma_n => [:Gamma, Rational(1, 1 << 40)], - :M => :M, :P1 => [:P1, proc{|v| [0, 30, 45, 60][v] * 60}], :P2 => :P2, :E_n => :En, + :M => :M, :P1_index => :P1, :P2 => :P2, :E_n => :En, }.collect{|dst_k, (src_k, sf)| ["#{dst_k}=".to_sym, ["glo#{src_k}".to_sym, sf || 1]] }.flatten(1))] @@ -480,7 +480,7 @@ def attach_lpp(msg) elsif delta_sec < -GPS::Time::Seconds_week / 2 then eph.WN -= 1 end - eph.fit_interval = [eph_src[:navFitFlag], eph.iodc, sys] + eph.fit_interval = (eph_src[:navFitFlag] != 0) eph } }