gps_pvt 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ffde7da5c82fa8eecc03dc1fb71c630ff95d8c1b016aefe4da64b63f8ab9e928
4
- data.tar.gz: 8a56df6b69e8f91cb888aa1135846b6db75a053bbd833e50c62bf0f4937a7157
3
+ metadata.gz: 83dff6013480dd4df4faacde170a901d712a605093fa006d0d4542c58f43ac45
4
+ data.tar.gz: 33728f6f9c4969f04ed528831e14977f3f90846b0f740ce0644f06de18ac7322
5
5
  SHA512:
6
- metadata.gz: 2889b55a9f925b9952ac1f29900bce98d8e0ab000418d7cecdd0405a2d81b84e70659ef4da271bb924231b7dcd80d8a550937478fbdb9f63ec0b38c0ea6d3061
7
- data.tar.gz: '08d73a274ee81613d1d44129cfbc1a9732cc886ef5ee48d3eb70113e7d700244ad5ea977abae2d3294d86ac142380c05ba7ccf6b266327f3d001f80be584b0dc'
6
+ metadata.gz: fd13f81c590a85ffeed54fe62dfb45858373cf687b08e5dc37bf45805f54398c50ad71f03e512a28015d214239e189c0581317d703cb4af99f4f9d258d162d12
7
+ data.tar.gz: 64df6a70a7b02f94e6f94c878ada85bc293871e5478698a5fdc285f77418fd2d27ecf9aece5b42ca197d6a3dc79ab9294f81b06411b83ca008f3428011245b83
data/README.md CHANGED
@@ -32,7 +32,7 @@ An attached executable is useful. After installation, type
32
32
 
33
33
  $ gps_pvt RINEX_or_UBX_file(s)
34
34
 
35
- The format of RINEX_or_UBX_file is automatically determined with its extention, such as .ubx will be treated as UBX format. If you want to specify the file format, instead of RINEX_or_UBX_file(s), use the following arguments:
35
+ The format of RINEX_or_UBX_file is automatically determined with its extension, such as .ubx will be treated as UBX format. A gz compressed file can be specified directly, and URI such as https://... is also acceptable since version 0.5.0. If you want to specify the file format, instead of RINEX_or_UBX_file(s), use the following arguments:
36
36
 
37
37
  --rinex_nav=filename
38
38
  --rinex_obs=filename
@@ -50,6 +50,7 @@ Additionally, the following command options *--key=value* are available.
50
50
  | elevation_mask_deg | numeric | satellite elevation mask specified in degrees. *ex) --elevation_mask_deg=10* | v0.3.0 |
51
51
  | start_time | time string | start time to perform solution. GPS, UTC and other formats are supported. *ex1) --start_time=1234:5678* represents 5678 seconds in 1234 GPS week, *ex2) --start_time="2000-01-01 00:00:00 UTC"* is in UTC format. | v0.3.3 |
52
52
  | end_time | time string | end time to perform solution. Its format is the same as start_time. | v0.3.3 |
53
+ | online_ephemeris | | automatically load ephemeris published online based on observation | v0.5.0 |
53
54
 
54
55
  ### For developer
55
56
 
data/exe/gps_pvt CHANGED
@@ -1,16 +1,19 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'gps_pvt'
4
+ require 'uri'
4
5
 
5
6
  # runnable quick example to solve PVT by using RINEX NAV/OBS or u-blox ubx
6
7
 
7
8
  $stderr.puts <<__STRING__
8
9
  Usage: #{__FILE__} GPS_file1 GPS_file2 ...
9
10
  As GPS_file, rinex_nav(*.YYn, *.YYh, *.YYq, *.YYg), rinex_obs(*.YYo), and ubx(*.ubx) format are currently supported.
11
+ (YY = last two digit of year)
10
12
  File format is automatically determined based on its extention described in above parentheses.
11
13
  If you want to specify its format manually, --rinex_(nav|obs)=file_name or --ubx=file_name are available.
12
14
  Supported RINEX versions are 2 and 3.
13
- Note: YY = last two digit of year.
15
+ A file having additional ".gz" extension is recognized as a file compressed by zlib.
16
+ Major URL such as http(s)://... is acceptable as an input file name.
14
17
  __STRING__
15
18
 
16
19
  options = []
@@ -54,6 +57,9 @@ options.reject!{|opt|
54
57
  end
55
58
  misc_options[opt[0]] = t
56
59
  true
60
+ when :online_ephemeris
61
+ misc_options[opt[0]] = opt[1]
62
+ true
57
63
  else
58
64
  false
59
65
  end
@@ -61,19 +67,45 @@ options.reject!{|opt|
61
67
 
62
68
  # Check file existence and extension
63
69
  files.collect!{|fname, ftype|
64
- raise "File not found: #{fname}" unless File::exist?(fname)
65
70
  ftype ||= case fname
66
- when /\.\d{2}[nhqg]$/; :rinex_nav
67
- when /\.\d{2}o$/; :rinex_obs
71
+ when /\.\d{2}[nhqg](?:\.gz)?$/; :rinex_nav
72
+ when /\.\d{2}o(?:\.gz)?$/; :rinex_obs
68
73
  when /\.ubx$/; :ubx
69
74
  else
70
75
  raise "Format cannot be guessed, use --(format, ex. rinex_nav)=#{fname}"
71
76
  end
77
+ fname = proc{
78
+ next fname if File::exist?(fname)
79
+ if uri = URI::parse(fname) and !uri.instance_of?(URI::Generic) then
80
+ next uri
81
+ end
82
+ raise "File not found: #{fname}"
83
+ }.call
72
84
  [fname, ftype]
73
85
  }
74
86
 
75
87
  rcv = GPS_PVT::Receiver::new(options)
76
88
 
89
+ proc{|src|
90
+ next unless src
91
+ loader = proc{|t_meas|
92
+ utc = Time::utc(*t_meas.c_tm)
93
+ y, yday = [:year, :yday].collect{|f| utc.send(f)}
94
+ uri = URI::parse(
95
+ "ftp://gssc.esa.int/gnss/data/daily/" +
96
+ "%04d/brdc/BRDC00IGS_R_%04d%03d0000_01D_MN.rnx.gz"%[y, y, yday])
97
+ rcv.parse_rinex_nav(uri)
98
+ uri
99
+ }
100
+ run_orig = rcv.method(:run)
101
+ eph_list = {}
102
+ rcv.define_singleton_method(:run){|meas, t_meas, *args|
103
+ w_d = [t_meas.week, (t_meas.seconds.to_i / 86400)]
104
+ eph_list[w_d] ||= loader.call(t_meas)
105
+ run_orig.call(meas, t_meas, *args)
106
+ }
107
+ }.call(misc_options[:online_ephemeris])
108
+
77
109
  proc{
78
110
  run_orig = rcv.method(:run)
79
111
  t_start, t_end = [nil, nil]
File without changes
@@ -4,6 +4,7 @@ Receiver class to be an top level interface to a user
4
4
  =end
5
5
 
6
6
  require_relative 'GPS'
7
+ require_relative 'util'
7
8
 
8
9
  module GPS_PVT
9
10
  class Receiver
@@ -547,22 +548,24 @@ class Receiver
547
548
  $stderr.puts ", found packets are %s"%[ubx_kind.inspect]
548
549
  end
549
550
 
550
- def parse_rinex_nav(fname)
551
+ def parse_rinex_nav(src)
552
+ fname = Util::get_txt(src)
551
553
  items = [
552
554
  @solver.gps_space_node,
553
555
  @solver.sbas_space_node,
554
556
  @solver.glonass_space_node,
555
557
  ].inject(0){|res, sn|
556
558
  loaded_items = sn.send(:read, fname)
557
- raise "Format error! (Not RINEX) #{fname}" if loaded_items < 0
559
+ raise "Format error! (Not RINEX) #{src}" if loaded_items < 0
558
560
  res + loaded_items
559
561
  }
560
- $stderr.puts "Read RINEX NAV file (%s): %d items."%[fname, items]
562
+ $stderr.puts "Read RINEX NAV file (%s): %d items."%[src, items]
561
563
  end
562
564
 
563
- def parse_rinex_obs(fname, &b)
565
+ def parse_rinex_obs(src, &b)
566
+ fname = Util::get_txt(src)
564
567
  after_run = b || proc{|pvt| puts pvt.to_s if pvt}
565
- $stderr.print "Reading RINEX observation file (%s)"%[fname]
568
+ $stderr.print "Reading RINEX observation file (%s)"%[src]
566
569
  types = nil
567
570
  glonass_freq = nil
568
571
  count = 0
@@ -0,0 +1,32 @@
1
+ require 'open-uri'
2
+ require 'tempfile'
3
+ require 'uri'
4
+ require 'zlib'
5
+
6
+ module GPS_PVT
7
+ module Util
8
+ class << self
9
+ def inflate(src)
10
+ Zlib::GzipReader.send(*(src.kind_of?(IO) ? [:new, src] : [:open, src]))
11
+ end
12
+ def get_txt(fname_or_uri)
13
+ is_uri = fname_or_uri.kind_of?(URI)
14
+ ((is_uri && (RUBY_VERSION >= "2.5.0")) ? URI : Kernel) \
15
+ .send(:open, fname_or_uri){|src|
16
+ is_gz = (src.content_type =~ /gzip/) if is_uri
17
+ is_gz ||= (fname_or_uri.to_s =~ /\.gz$/)
18
+ is_file = src.kind_of?(File) || src.kind_of?(Tempfile)
19
+
20
+ return src.path if ((!is_gz) and is_file)
21
+
22
+ Tempfile::open(File::basename($0, '.*')){|dst|
23
+ dst.binmode
24
+ dst.write((is_gz ? inflate(is_file ? src.path : src) : src).read)
25
+ dst.rewind
26
+ dst.path
27
+ }
28
+ }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GPS_PVT
4
- VERSION = "0.4.1"
4
+ VERSION = "0.5.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.4.1
4
+ version: 0.5.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-03-30 00:00:00.000000000 Z
11
+ date: 2022-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -93,11 +93,12 @@ files:
93
93
  - ext/ninja-scan-light/tool/swig/spec/GPS_spec.rb
94
94
  - ext/ninja-scan-light/tool/swig/spec/SylphideMath_spec.rb
95
95
  - gps_pvt.gemspec
96
+ - gps_pvt.rbs
96
97
  - lib/gps_pvt.rb
97
98
  - lib/gps_pvt/receiver.rb
98
99
  - lib/gps_pvt/ubx.rb
100
+ - lib/gps_pvt/util.rb
99
101
  - lib/gps_pvt/version.rb
100
- - sig/gps_pvt.rbs
101
102
  homepage: https://github.com/fenrir-naru/gps_pvt
102
103
  licenses: []
103
104
  metadata: