gps_pvt 0.10.0 → 0.10.2

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.
@@ -875,10 +875,10 @@ __RINEX_CLK_TEXT__
875
875
  expect(pvt.vdop).to be_within(1E-2).of(1.87)
876
876
  expect(pvt.tdop).to be_within(1E-2).of(1.08)
877
877
  expect(pvt.velocity.to_a).to eq([:e, :n, :u].collect{|k| pvt.velocity.send(k)})
878
- expect(pvt.velocity.north).to be_within(1E-2).of(-0.86) # north
879
- expect(pvt.velocity.east) .to be_within(1E-2).of(-1.10) # east
880
- expect(pvt.velocity.down) .to be_within(1E-2).of(-0.22) # down
881
- expect(pvt.receiver_error_rate).to be_within(1E-2).of(-1061.86)
878
+ expect(pvt.velocity.north).to be_within(1E-2).of(-0.68) # north
879
+ expect(pvt.velocity.east) .to be_within(1E-2).of(-0.90) # east
880
+ expect(pvt.velocity.down) .to be_within(1E-2).of(0.26) # down
881
+ expect(pvt.receiver_error_rate).to be_within(1E-2).of(-1062.14)
882
882
  expect(pvt.G.rows).to eq(6)
883
883
  expect(pvt.W.rows).to eq(6)
884
884
  expect(pvt.delta_r.rows).to eq(6)
@@ -942,9 +942,9 @@ __RINEX_CLK_TEXT__
942
942
  expect(t_arv).to be_a_kind_of(GPS::Time)
943
943
  expect(usr_pos).to be_a_kind_of(Coordinate::XYZ)
944
944
  expect(usr_vel).to be_a_kind_of(Coordinate::XYZ)
945
- weight, range_c, range_r, rate_rel_neg, *los_neg = rel_prop
946
- weight = 1
947
- [weight, range_c, range_r, rate_rel_neg] + los_neg
945
+ weight_range, range_c, range_r, weight_rate, rate_rel_neg, *los_neg = rel_prop
946
+ weight_range = 1
947
+ [weight_range, range_c, range_r, weight_rate, rate_rel_neg] + los_neg
948
948
  }
949
949
  solver.hooks[:update_position_solution] = proc{|mat_G, mat_W, mat_delta_r, temp_pvt|
950
950
  expect(temp_pvt).to be_a_kind_of(GPS::PVT)
@@ -1,3 +1,5 @@
1
+ require 'set'
2
+
1
3
  module GPS_PVT
2
4
  end
3
5
 
@@ -261,10 +263,10 @@ resolve_tree = proc{|root|
261
263
  res
262
264
  }
263
265
 
264
- # This proc is useless because assumed automatic tagging
265
- # does not require to re-order based on manual tags or class numbers
266
+ # This proc is used to re-order for non-automatic tagging transformation
266
267
  # @see https://stackoverflow.com/a/31450137
267
268
  get_universal_class_number = proc{|type|
269
+ # TODO where is CHOICE class number definition?
268
270
  next get_universal_class_number.call(type[1][:root][0][:type]) if type[0] == :CHOICE
269
271
  { # @see Table.1 unless any comment
270
272
  :BOOLEAN => 1,
@@ -274,6 +276,9 @@ resolve_tree = proc{|root|
274
276
  :NULL => 5,
275
277
  :ENUMERATED => 10,
276
278
  :SEQUENCE => 16,
279
+ :SEQUENCE_OF => 16,
280
+ :SET => 17,
281
+ :SET_OF => 17,
277
282
  :NumericString => 18, # @see Table.6
278
283
  :PrintableString => 19, # @see Table.6
279
284
  :IA5String => 22, # @see Table.6
@@ -281,6 +286,23 @@ resolve_tree = proc{|root|
281
286
  :UTCTime => 23, # @see 43.3
282
287
  }[type[0]]
283
288
  }
289
+
290
+ reorder_children = proc{|type_opts|
291
+ # reordering when automatic tagging transformation is not selected
292
+ tags = Set[]
293
+ [type_opts[:root], type_opts[:extension]].compact.each{|items|
294
+ items.collect!{|v|
295
+ tag = v[:type][1][:tag]
296
+ tag_class_num = case tag
297
+ when Array; [{"APPLICATION" => 1, "PRIVATE" => 3}[tag[0]], tag[1]]
298
+ when Integer; [2, tag] # (Context-specific)
299
+ else; [0, get_universal_class_number.call(v[:type])] # UNIVERSAL
300
+ end
301
+ raise unless tags.add?(tag_class_num) # Identical tag is already existed!
302
+ [v, tag_class_num]
303
+ }.sort!{|a, b| a[1] <=> b[1]}.collect!{|v| v[0]}
304
+ }
305
+ }
284
306
 
285
307
  prepare_coding = proc{|tree|
286
308
  next tree.each{|k, v|
@@ -313,7 +335,8 @@ resolve_tree = proc{|root|
313
335
  }
314
336
  when :BIT_STRING, :OCTET_STRING
315
337
  opts[:size_range] = find_range.call(opts, :size)
316
- when :SEQUENCE
338
+ when :SEQUENCE, :SET
339
+ reorder_children.call(opts) if (opts[:automatic_tagging] == false) # only for SET
317
340
  (opts[:root] + (opts[:extension] || [])).each.with_index{|v, i|
318
341
  v[:name] = v[:name] ? v[:name].to_sym : i
319
342
  v[:type][1][:typename] ||= v[:name] if v[:name].kind_of?(Symbol) && v[:type] # for debugger
@@ -325,11 +348,11 @@ resolve_tree = proc{|root|
325
348
  v2[:name]
326
349
  } if v[:group]
327
350
  }
328
- when :SEQUENCE_OF
351
+ when :SEQUENCE_OF, :SET_OF
329
352
  opts[:size_range] = find_range.call(opts, :size)
330
353
  prepare_coding.call(opts)
331
354
  when :CHOICE
332
- # Skip reordering based on automatic tagging assumption
355
+ reorder_children.call(opts) if (opts[:automatic_tagging] == false)
333
356
  opts[:extension] = opts[:extension].collect{|v|
334
357
  v[:group] || [v] # 22. Note says "Version brackets have no effect"
335
358
  }.flatten(1) if opts[:extension]
@@ -372,7 +395,7 @@ generate_skeleton = proc{|tree, data|
372
395
  when :BIT_STRING, :OCTET_STRING
373
396
  data || ({:BIT_STRING => [0], :OCTET_STRING => [0xFF]}[type] \
374
397
  * (opts[:size_range][:root].first rescue 0))
375
- when :SEQUENCE
398
+ when :SEQUENCE, :SET
376
399
  data ||= {}
377
400
  Hash[*((opts[:root] + (opts[:extension] || [])).collect{|v|
378
401
  if v[:group] then
@@ -386,7 +409,7 @@ generate_skeleton = proc{|tree, data|
386
409
  end
387
410
  end
388
411
  }.compact.flatten(2))]
389
- when :SEQUENCE_OF
412
+ when :SEQUENCE_OF, :SET_OF
390
413
  next data.collect{|v| generate_skeleton.call(opts, v)} if data
391
414
  v = Marshal::dump(generate_skeleton.call(opts))
392
415
  (opts[:size_range][:root].first rescue 0).times.collect{
@@ -488,7 +511,7 @@ encode = proc{|tree, data|
488
511
  end
489
512
  end
490
513
  res += data.collect{|v| "%0#{bits}b"%[v]}.join
491
- when :SEQUENCE
514
+ when :SEQUENCE, :SET
492
515
  opt_def_flags, root_encoded = opts[:root].collect{|v| # 18.2
493
516
  has_elm = data.include?(v[:name])
494
517
  elm = data[v[:name]]
@@ -532,7 +555,7 @@ encode = proc{|tree, data|
532
555
  end
533
556
 
534
557
  "#{ext_bit}#{opt_def_flags.join}#{root_encoded.join}#{ext_encoded}"
535
- when :SEQUENCE_OF
558
+ when :SEQUENCE_OF, :SET_OF
536
559
  ext_bit, len_enc = case (cat = opts[:size_range].belong_to(data.size))
537
560
  when :additional
538
561
  # 19.4 -> 10.9.4.2(semi_constrained_whole_number)
@@ -691,7 +714,7 @@ decode = proc{|tree, str|
691
714
  end
692
715
  end
693
716
  str.slice!(0, bits * len).scan(/.{#{bits}}/).collect{|chunk| chunk.to_i(2)}
694
- when :SEQUENCE
717
+ when :SEQUENCE, :SET
695
718
  has_extension = (opts[:extension] && (str.slice!(0) == '1'))
696
719
  data = Hash[*(
697
720
  opts[:root].collect{|v| [v[:name], v[:default]] if v[:default]}.compact.flatten(1)
@@ -709,7 +732,7 @@ decode = proc{|tree, str|
709
732
  v[:group] ? decoded.to_a : [[v[:name], decoded]]
710
733
  }.compact.flatten(2))]) if has_extension
711
734
  data
712
- when :SEQUENCE_OF
735
+ when :SEQUENCE_OF, :SET_OF
713
736
  len_dec = if opts[:size_range][:additional] && (str.slice!(0) == '1') then
714
737
  # 19.4 -> 10.9.4.2(semi_constrained_whole_number)
715
738
  :length_otherwise
@@ -46,10 +46,10 @@ rule
46
46
  DefinitiveNameAndNumberForm : identifier LCBRACE DefinitiveNumberForm RCBRACE
47
47
 
48
48
  TagDefault :
49
- EXPLICIT TAGS {raise} # not supported
50
- | IMPLICIT TAGS {raise} # not supported
51
- | AUTOMATIC TAGS
52
- | {raise} # not supported
49
+ EXPLICIT TAGS {@tags = val[0]}
50
+ | IMPLICIT TAGS {@tags = val[0]}
51
+ | AUTOMATIC TAGS {@tags = val[0]} # 12.3
52
+ | {@tags = :EXPLICIT} # 12.2
53
53
 
54
54
  ExtensionDefault :
55
55
  EXTENSIBILITY IMPLIED
@@ -179,8 +179,8 @@ rule
179
179
  #| RelativeOIDType
180
180
  | SequenceType
181
181
  | SequenceOfType
182
- #| SetType
183
- #| SetOfType
182
+ | SetType
183
+ | SetOfType
184
184
  | TaggedType
185
185
  | UTCTime # 43. Universal time
186
186
 
@@ -199,32 +199,34 @@ rule
199
199
  | ObjectClassFieldValue
200
200
 
201
201
  BuiltinValue : # 16.9
202
- BitStringValue
203
- | BooleanValue
204
- | CharacterStringValue
205
- | ChoiceValue
202
+ BitStringValue # String, Array, Hash (possible returned value, same below)
203
+ | BooleanValue # true/false
204
+ | CharacterStringValue # String, Array, Hash
205
+ | ChoiceValue # Hash
206
206
  #| EmbeddedPDVValue
207
- | EnumeratedValue
207
+ | EnumeratedValue # String
208
208
  #| ExternalValue
209
209
  #| InstanceOfValue
210
- | IntegerValue
211
- | NullValue
212
- | ObjectIdentifierValue
213
- | OctetStringValue
214
- | RealValue
210
+ | IntegerValue # Number, String
211
+ | NullValue # nil
212
+ | ObjectIdentifierValue # Array
213
+ | OctetStringValue # String, Hash
214
+ | RealValue # Number, Hash(M * B^E), String([PLUS|MINUS]_INFINITY)
215
215
  #| RelativeOIDValue
216
- | SequenceValue
217
- | SequenceOfValue
218
- #| SetValue
219
- #| SetOfValue
216
+ | SequenceValue # Hash
217
+ | SequenceOfValue # Array, Hash
218
+ | SetValue # Hash
219
+ | SetOfValue # Array, Hash
220
220
  #| TaggedValue
221
221
 
222
222
  #ReferencedValue : DefinedValue | ValueFromObject # 16.11
223
223
  #ReferencedValue : identifier
224
224
 
225
+ NamedValue : identifier Value {result = {val[0] => val[1]}} # 16.13
226
+
225
227
  # 17. Notation for the boolean type
226
228
  BooleanType : BOOLEAN
227
- BooleanValue : TRUE | FALSE
229
+ BooleanValue : TRUE {result = true} | FALSE {result = false}
228
230
 
229
231
  # 18. Notation for the integer type
230
232
  IntegerType :
@@ -240,7 +242,7 @@ rule
240
242
  number
241
243
  | MINUS number {result = -val[1]}
242
244
 
243
- IntegerValue :
245
+ IntegerValue : # returning Number or String
244
246
  SignedNumber
245
247
  | identifier
246
248
 
@@ -299,13 +301,13 @@ rule
299
301
  # 20. Notation for the real type
300
302
  RealType : REAL
301
303
 
302
- RealValue :
304
+ RealValue : # returning Number, Hash (M * B^E) or String ([PLUS|MINUS]_INFINITY)
303
305
  NumericRealValue
304
306
  | SpecialRealValue
305
307
  NumericRealValue :
306
308
  realnumber
307
- | MINUS realnumber
308
- | SequenceValue
309
+ | MINUS realnumber {result = -val[1]}
310
+ | SequenceValue # 20.3 in M * B^E format
309
311
  SpecialRealValue : PLUS_INFINITY | MINUS_INFINITY
310
312
 
311
313
  # 21. Notation for the bitstring
@@ -319,22 +321,22 @@ rule
319
321
  identifier LCBRACE number RCBRACE {result = {val[0] => val[2]}}
320
322
  | identifier LCBRACE DefinedValue RCBRACE {result = {val[0] => val[2]}}
321
323
 
322
- BitStringValue :
324
+ BitStringValue : # returning String, Array or Hash
323
325
  bstring
324
326
  | hstring
325
- | LBRACE IdentifierList RBRACE
326
- | LBRACE RBRACE
327
- | CONTAINING Value
327
+ | LBRACE IdentifierList RBRACE {result = val[1]}
328
+ | LBRACE RBRACE {result = []}
329
+ | CONTAINING Value {result = {:containing => val[1]}}
328
330
  IdentifierList :
329
- identifier
330
- | IdentifierList COMMA identifier
331
+ identifier {result = [val[0]]}
332
+ | IdentifierList COMMA identifier {result << val[2]}
331
333
 
332
334
  # 22. Notation for the octetstring type
333
335
  OctetStringType : OCTET STRING {result = {:type => :OCTET_STRING}}
334
- OctetStringValue :
336
+ OctetStringValue : # returning String or Hash
335
337
  bstring
336
338
  | hstring
337
- | CONTAINING Value
339
+ | CONTAINING Value {result = {:containing => val[1]}}
338
340
 
339
341
  # 23. Notation for the null type
340
342
  NullType : NULL
@@ -409,12 +411,12 @@ rule
409
411
  | NamedType DEFAULT Value {result = val[0].merge({:default => val[2]})}
410
412
  | COMPONENTS OF Type {result = val[2]; raise} /* TODO 24.4 says only root components of SEQUENCE are included */
411
413
 
412
- SequenceValue :
413
- LBRACE ComponentValueList RBRACE
414
- | LBRACE RBRACE
414
+ SequenceValue : # returning Hash
415
+ LBRACE ComponentValueList RBRACE {result = val[1]}
416
+ | LBRACE RBRACE {result = {}}
415
417
  ComponentValueList :
416
- NamedValue
417
- | ComponentValueList COMMA NamedValue
418
+ NamedValue {result = val[0]}
419
+ | ComponentValueList COMMA NamedValue {result = val[0].merge(val[2])}
418
420
 
419
421
  # 25 Notation for sequence-of types
420
422
  SequenceOfType :
@@ -423,19 +425,50 @@ rule
423
425
  }
424
426
  SequenceOfType_t : Type | NamedType
425
427
 
426
- SequenceOfValue :
427
- LBRACE ValueList RBRACE
428
- | LBRACE NamedValueList RBRACE
429
- | LBRACE RBRACE
428
+ SequenceOfValue : # returning Array or Hash
429
+ LBRACE ValueList RBRACE {result = val[1]}
430
+ | LBRACE NamedValueList RBRACE {result = val[1]}
431
+ | LBRACE RBRACE {result = {}}
430
432
  ValueList :
431
- Value
432
- | ValueList COMMA Value
433
+ Value {result = [val[0]]}
434
+ | ValueList COMMA Value {result << val[2]}
433
435
  NamedValueList :
434
- NamedValue
435
- | NamedValueList COMMA NamedValue
436
+ NamedValue {result = val[0]}
437
+ | NamedValueList COMMA NamedValue {result = val[0].merge(val[2])}
438
+
439
+ # 26. Notation for set types
440
+ SetType :
441
+ /*SET LBRACE RBRACE
442
+ | SET LBRACE ExtensionAndException OptionalExtensionMarker RBRACE
443
+ |*/ SET LBRACE ComponentTypeLists RBRACE {
444
+ # 26.3
445
+ val[2].merge!({:automatic_tagging => false}) \
446
+ if (@tags != :AUTOMATIC) \
447
+ || (val[2][:root] + (val[2][:extension] || [])).any?{|v|
448
+ v[:type][1][:tag] rescue false
449
+ }
450
+ result = {:type => [val[0], val[2]]}
451
+ }
452
+
453
+ SetValue : SequenceValue # returning Hash
454
+
455
+ # 27. Notation for set-of types
456
+ SetOfType :
457
+ SET OF SetOfType_t {
458
+ result = {:type => ["#{val[0]}_#{val[1]}".to_sym, val[2]]}
459
+ }
460
+ SetOfType_t : Type | NamedType
461
+
462
+ SetOfValue : SequenceOfValue # returning Array or Hash
436
463
 
437
464
  # 28. Notation for choice types
438
465
  ChoiceType : CHOICE LBRACE AlternativeTypeLists RBRACE {
466
+ # 28.2
467
+ val[2].merge!({:automatic_tagging => false}) \
468
+ if (@tags != :AUTOMATIC) \
469
+ || (val[2][:root] + (val[2][:extension] || [])).any?{|v|
470
+ v[:type][1][:tag] rescue false
471
+ }
439
472
  result = {:type => [val[0], val[2]]}
440
473
  }
441
474
  /*
@@ -472,14 +505,30 @@ rule
472
505
  NamedType {result = [val[0]]}
473
506
  | AlternativeTypeList COMMA NamedType {result << val[2]}
474
507
 
475
- ChoiceValue : identifier COLON Value
508
+ ChoiceValue : # returning Hash
509
+ identifier COLON Value {result = {val[0] => val[2]}}
476
510
 
477
511
  # 30. Notation for tagged types
478
- TaggedType :
512
+ /*TaggedType :
479
513
  Tag Type
480
514
  | Tag IMPLICIT Type
481
- | Tag EXPLICIT Type
482
- Tag : LBRACKET Class ClassNumber RBRACKET
515
+ | Tag EXPLICIT Type*/
516
+ TaggedType :
517
+ Tag TaggingConstruction Type {
518
+ result = val[2] # => {} having :type or :typeref keys
519
+ result[:type] = [result[:type]].flatten(1)
520
+ (result[:type][1] ||= {}).merge!({:tag => val[0]})
521
+ # TODO 30.6 c) to check whether Type is an untagged CHOICE after extraction of ReferencedType
522
+ result[:type][1].merge!({:tag_cnstr => val[1]}) if val[1]
523
+ }
524
+ TaggingConstruction :
525
+ IMPLICIT {result = nil}
526
+ | EXPLICIT # 30.6 a)
527
+ | {result = :EXPLICIT if @tags == :EXPLICIT} # 30.6 b)
528
+ Tag :
529
+ LBRACKET Class ClassNumber RBRACKET
530
+ {result = val[1] ? val[1..2] : val[2]}
531
+ # if class specified, array is returned; otherwise, integer.
483
532
  ClassNumber :
484
533
  number
485
534
  | DefinedValue
@@ -494,12 +543,12 @@ rule
494
543
  # 31. Notation for the object identifier type
495
544
  ObjectIdentifierType : OBJECT IDENTIFIER
496
545
 
497
- ObjectIdentifierValue :
498
- LBRACE ObjIdComponentsList RBRACE
499
- | LBRACKET DefinedValue ObjIdComponentsList RBRACKET
546
+ ObjectIdentifierValue : # returning Array
547
+ LBRACE ObjIdComponentsList RBRACE {result = val[1]}
548
+ | LBRACKET DefinedValue ObjIdComponentsList RBRACKET {result = [val[1]] + val[2]}
500
549
  ObjIdComponentsList :
501
- ObjIdComponents
502
- | ObjIdComponentsList ObjIdComponents
550
+ ObjIdComponents {result = [val[0]]}
551
+ | ObjIdComponentsList ObjIdComponents {result << val[1]}
503
552
  ObjIdComponents :
504
553
  NameForm
505
554
  | NumberForm
@@ -509,13 +558,13 @@ rule
509
558
  NumberForm :
510
559
  number
511
560
  | DefinedValue
512
- NameAndNumberForm : identifier LCBRACE NumberForm RCBRACE
561
+ NameAndNumberForm : identifier LCBRACE NumberForm RCBRACE {result = val.values_at(0, 2)}
513
562
 
514
563
  # 36. Notation for character string types
515
564
  CharacterStringType :
516
565
  RestrictedCharacterStringType
517
566
  | UnrestrictedCharacterStringType
518
- CharacterStringValue :
567
+ CharacterStringValue : # returning String, Array or Hash
519
568
  RestrictedCharacterStringValue
520
569
  | UnrestrictedCharacterStringValue
521
570
 
@@ -535,26 +584,26 @@ rule
535
584
  | VideotexString*/
536
585
  | VisibleString
537
586
 
538
- RestrictedCharacterStringValue :
587
+ RestrictedCharacterStringValue : # returning String or Array
539
588
  cstring
540
589
  | CharacterStringList
541
590
  | Quadruple
542
591
  | Tuple
543
- CharacterStringList : LBRACE CharSyms RBRACE
592
+ CharacterStringList : LBRACE CharSyms RBRACE {result = val[1]}
544
593
  CharSyms :
545
- CharsDefn
546
- | CharSyms COMMA CharsDefn
594
+ CharsDefn {result = [val[0]]}
595
+ | CharSyms COMMA CharsDefn {result << val[2]}
547
596
  CharsDefn :
548
597
  cstring
549
598
  | Quadruple
550
599
  | Tuple
551
600
  | DefinedValue
552
- Quadruple : LBRACE Group COMMA Plane COMMA Row COMMA Cell RBRACE
601
+ Quadruple : LBRACE Group COMMA Plane COMMA Row COMMA Cell RBRACE {result = val.values_at(1, 3, 5, 7)}
553
602
  Group : number
554
603
  Plane : number
555
604
  Row : number
556
605
  Cell : number
557
- Tuple : LBRACE TableColumn COMMA TableRow RBRACE
606
+ Tuple : LBRACE TableColumn COMMA TableRow RBRACE {result = val.values_at(1, 3)}
558
607
  TableColumn : number
559
608
  TableRow : number
560
609
 
@@ -60,79 +60,6 @@ end
60
60
 
61
61
  module GPS
62
62
 
63
- # These ephemeris helper functions will be removed
64
- # when native functions are available in GPS.i
65
- class Ephemeris
66
- URA_TABLE = [
67
- 2.40, 3.40, 4.85, 6.85, 9.65, 13.65, 24.00, 48.00,
68
- 96.00, 192.00, 384.00, 768.00, 1536.00, 3072.00, 6144.00]
69
- def URA_index=(idx)
70
- send(:URA=, (idx >= URA_TABLE.size) ? (URA_TABLE[-1] * 2) : (idx < 0 ? -1 : URA_TABLE[idx]))
71
- end
72
- def URA_index
73
- ura = send(:URA)
74
- (ura < 0) ? -1 : URA_TABLE.find_index{|v| ura <= v}
75
- end
76
- proc{
77
- orig = instance_method(:fit_interval=)
78
- define_method(:fit_interval=){|args|
79
- args = case args
80
- when Array
81
- flag, iodc, sys = args
82
- hr = case (sys ||= :GPS)
83
- when :GPS, :gps
84
- (flag == 0) ? 4 : case iodc
85
- when 240..247; 8
86
- when 248..255, 496; 14
87
- when 497..503; 26
88
- when 504..510; 50
89
- when 511, 752..756; 74
90
- when 757..763; 98
91
- when 764..767, 1088..1010; 122
92
- when 1011..1020; 146
93
- else; 6
94
- end
95
- when :QZSS, :qzss
96
- raise unless flag == 0 # TODO how to treat fit_interval > 2 hrs
97
- 2
98
- else; raise
99
- end
100
- hr * 60 * 60
101
- else
102
- args
103
- end
104
- orig.bind(self).call(args)
105
- }
106
- }.call
107
- end
108
- class Ephemeris_SBAS
109
- URA_TABLE = [ # Table 2-3 in DO-229E
110
- 2.0, 2.8, 4.0, 5.7, 8.0, 11.3, 16.0, 32.0,
111
- 64.0, 128.0, 256.0, 512.0, 1024.0, 2048.0, 4096.0]
112
- def URA_index=(idx)
113
- send(:URA=, (idx >= URA_TABLE.size) ? (URA_TABLE[-1] * 2) : (idx < 0 ? -1 : URA_TABLE[idx]))
114
- end
115
- def URA_index
116
- ura = send(:URA)
117
- (ura < 0) ? -1 : URA_TABLE.find_index{|v| ura <= v}
118
- end
119
- end
120
- class Ephemeris_GLONASS
121
- F_T_TABLE = [ # Table 4.4 in ICD 5.1
122
- 1, 2, 2.5, 4, 5, 7, 10, 12, 14, 16, 32, 64, 128, 256, 512, 1024]
123
- def F_T_index=(idx)
124
- send(:F_T=, (idx >= F_T_TABLE.size) ? (F_T_TABLE[-1] * 2) : (idx < 0 ? -1 : F_T_TABLE[idx]))
125
- end
126
- def F_T_index
127
- f_t = send(:F_T)
128
- (f_t < 0) ? -1 : F_T_TABLE.find_index{|v| f_t <= v}
129
- end
130
- def NA
131
- # based on TimeProperties::date2raw
132
- self.day_of_year + [1, 367, 732, 1097][(self.year - 1996) % 4]
133
- end
134
- end
135
-
136
63
  [
137
64
  Ionospheric_UTC_Parameters,
138
65
  Ephemeris, Ephemeris_SBAS, Ephemeris_GLONASS,
@@ -38,20 +38,21 @@ class Receiver
38
38
  ] + (pvt.rel_ENU.to_a rescue [nil] * 3)
39
39
  }
40
40
  ]] + [proc{
41
- labels = [:g, :p, :h, :v, :t].collect{|k| "#{k}dop".to_sym}
41
+ labels = [:g, :p, :h, :v, :t].collect{|k| "#{k}dop".to_sym} \
42
+ + [:h, :v, :t].collect{|k| "#{k}sigma".to_sym}
42
43
  [
43
44
  labels,
44
45
  proc{|pvt|
45
- next [nil] * 5 unless pvt.position_solved?
46
+ next [nil] * 8 unless pvt.position_solved?
46
47
  labels.collect{|k| pvt.send(k)}
47
48
  }
48
49
  ]
49
50
  }.call] + [[
50
- [:v_north, :v_east, :v_down, :receiver_clock_error_dot_ms],
51
+ [:v_north, :v_east, :v_down, :receiver_clock_error_dot_ms, :vel_sigma],
51
52
  proc{|pvt|
52
53
  next [nil] * 4 unless pvt.velocity_solved?
53
54
  [:north, :east, :down].collect{|k| pvt.velocity.send(k)} \
54
- + [pvt.receiver_error_rate]
55
+ + [pvt.receiver_error_rate, pvt.vel_sigma]
55
56
  }
56
57
  ]] + [
57
58
  [:used_satellites, proc{|pvt| pvt.used_satellites}],
data/lib/gps_pvt/rtcm3.rb CHANGED
@@ -132,7 +132,7 @@ class RTCM3
132
132
  103 => 1,
133
133
  104 => 1,
134
134
  105 => 1,
135
- 106 => [2, proc{|v| [0, 30, 45, 60][v] * 60}], # [s]
135
+ 106 => 2,
136
136
  107 => [12, proc{|v|
137
137
  hh, mm, ss = [v >> 7, (v & 0x7E) >> 1, (v & 0x1) > 0 ? 30 : 0]
138
138
  hh * 3600 + mm * 60 + ss # [sec]
@@ -314,7 +314,7 @@ class RTCM3
314
314
  def params
315
315
  # TODO WN is truncated to 0-1023
316
316
  res = Hash[*(KEY2IDX.collect{|k, i| [k, self[i][0]]}.flatten(1))]
317
- res[:fit_interval] = [self[29][0], res[:iodc]]
317
+ res[:fit_interval] = (self[29][0] != 0)
318
318
  res
319
319
  end
320
320
  end
@@ -334,7 +334,7 @@ class RTCM3
334
334
  # TODO insufficient: :n => ?(String4); extra: :P3
335
335
  # TODO generate time with t_b, N_T, NA, N_4
336
336
  # TODO GPS.i is required to modify to generate EPhemeris_with_GPS_Time
337
- k_i = {:svid => 1, :freq_ch => 2, :P1 => 5, :t_k => 6, :B_n => 7, :P2 => 8, :t_b => 9,
337
+ k_i = {:svid => 1, :freq_ch => 2, :P1_index => 5, :t_k => 6, :B_n => 7, :P2 => 8, :t_b => 9,
338
338
  :xn_dot => 10, :xn => 11, :xn_ddot => 12,
339
339
  :yn_dot => 13, :yn => 14, :yn_ddot => 15,
340
340
  :zn_dot => 16, :zn => 17, :zn_ddot => 18,
@@ -362,7 +362,7 @@ class RTCM3
362
362
  def params
363
363
  # TODO PRN = svid + 192, WN is truncated to 0-1023
364
364
  res = Hash[*(KEY2IDX.collect{|k, i| [k, self[i][0]]}.flatten(1))]
365
- res[:fit_interval] = [self[29][0], res[:iodc], :QZSS]
365
+ res[:fit_interval] = (self[29][0] != 0)
366
366
  res
367
367
  end
368
368
  end
data/lib/gps_pvt/supl.rb CHANGED
@@ -353,7 +353,7 @@ class SUPL_Client
353
353
  eph.WN -= 1
354
354
  end
355
355
  eph.iode = eph.iodc & 0xFF
356
- eph.fit_interval = [eph_src[:ephemFitFlag], eph.iodc]
356
+ eph.fit_interval = (eph_src[:ephemFitFlag] != 0)
357
357
  eph
358
358
  }
359
359
  }
@@ -403,7 +403,7 @@ class SUPL_Client
403
403
  :zn => [:Z, Rational(1000, 1 << 11)], :zn_dot => [:Zdot, Rational(1000, 1 << 20)], :zn_ddot => [:Zdotdot, Rational(1000, 1 << 30)],
404
404
  :tau_n => [:Tau, Rational(1, 1 << 30)],
405
405
  :gamma_n => [:Gamma, Rational(1, 1 << 40)],
406
- :M => :M, :P1 => [:P1, proc{|v| [0, 30, 45, 60][v] * 60}], :P2 => :P2, :E_n => :En,
406
+ :M => :M, :P1_index => :P1, :P2 => :P2, :E_n => :En,
407
407
  }.collect{|dst_k, (src_k, sf)|
408
408
  ["#{dst_k}=".to_sym, ["glo#{src_k}".to_sym, sf || 1]]
409
409
  }.flatten(1))]
@@ -480,7 +480,7 @@ class SUPL_Client
480
480
  elsif delta_sec < -GPS::Time::Seconds_week / 2 then
481
481
  eph.WN -= 1
482
482
  end
483
- eph.fit_interval = [eph_src[:navFitFlag], eph.iodc, sys]
483
+ eph.fit_interval = (eph_src[:navFitFlag] != 0)
484
484
  eph
485
485
  }
486
486
  }