gps_pvt 0.9.2 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -380,6 +380,32 @@ struct MatrixBuilder_Dependency<
380
380
  (MatrixViewProperty<ViewType_R>::transposed ? nR_R : nC_R)>,
381
381
  ViewType> > {};
382
382
 
383
+ template <
384
+ class T, class T_op,
385
+ class T2, class T3, class T4, class T5,
386
+ class ViewType,
387
+ int nR_L, int nC_L, class ViewType_L,
388
+ int nR_R, int nC_R, class ViewType_R,
389
+ bool horizontal_R>
390
+ struct MatrixBuilder_Dependency<
391
+ Matrix_Frozen<
392
+ T,
393
+ Array2D_Operator<T_op, Array2D_Operator_Stack<
394
+ Matrix_Frozen<T2, Array2D_Fixed<T3, nR_L, nC_L>, ViewType_L>,
395
+ Matrix_Frozen<T4, Array2D_Fixed<T5, nR_R, nC_R>, ViewType_R>,
396
+ horizontal_R> >,
397
+ ViewType> >
398
+ : public MatrixBuilder_Dependency<
399
+ Matrix_Frozen<
400
+ T,
401
+ Array2D_Fixed<
402
+ T,
403
+ (MatrixViewProperty<ViewType_L>::transposed ? nC_L : nR_L)
404
+ + (horizontal_R ? 0 : (MatrixViewProperty<ViewType_R>::transposed ? nC_R : nR_R)),
405
+ (MatrixViewProperty<ViewType_L>::transposed ? nR_L : nC_L)
406
+ + (horizontal_R ? (MatrixViewProperty<ViewType_R>::transposed ? nR_R : nC_R) : 0)>,
407
+ ViewType> > {};
408
+
383
409
  // For optimization of local temporary matrix
384
410
  template <
385
411
  template <class, class, class> class MatrixT,
@@ -16,6 +16,7 @@
16
16
  %include std_common.i
17
17
  %include std_string.i
18
18
  %include exception.i
19
+ %include std_except.i
19
20
 
20
21
  //%import "SylphideMath.i"
21
22
 
@@ -29,7 +30,13 @@ type set_ ## name (const type &v) {
29
30
  %enddef
30
31
 
31
32
  #if !defined(SWIGIMPORTED)
32
- %header {
33
+ %exceptionclass native_exception;
34
+ %typemap(throws,noblock=1) native_exception {
35
+ $1.regenerate();
36
+ SWIG_fail;
37
+ }
38
+ %ignore native_exception;
39
+ %inline {
33
40
  struct native_exception : public std::exception {
34
41
  #if defined(SWIGRUBY)
35
42
  int state;
@@ -67,22 +74,15 @@ struct native_exception : public std::exception {
67
74
  }
68
75
  }
69
76
  #endif
70
- %exception each {
77
+ %typemap(in,numinputs=0) const void *check_block {
71
78
  #ifdef SWIGRUBY
72
79
  if(!rb_block_given_p()){
73
- return rb_enumeratorize(self, ID2SYM(rb_intern("each")), argc, argv);
80
+ return rb_enumeratorize(self, ID2SYM(rb_frame_callee()), argc, argv);
74
81
  }
75
82
  #endif
76
- try {
77
- $action
78
- } catch (const native_exception &e) {
79
- e.regenerate();
80
- SWIG_fail;
81
- } catch (const std::exception& e) {
82
- SWIG_exception(SWIG_RuntimeError, e.what());
83
- }
84
83
  }
85
- void each() const {
84
+ %catches(native_exception) each;
85
+ void each(const void *check_block) const {
86
86
  for(int i(0); i < 3; ++i){
87
87
  #ifdef SWIGRUBY
88
88
  int state;
@@ -48,9 +48,16 @@ inline std::string to_string(const T &value){
48
48
  %include std_common.i
49
49
  %include std_string.i
50
50
  %include exception.i
51
+ %include std_except.i
51
52
 
52
53
  #if !defined(SWIGIMPORTED)
53
- %header {
54
+ %exceptionclass native_exception;
55
+ %typemap(throws,noblock=1) native_exception {
56
+ $1.regenerate();
57
+ SWIG_fail;
58
+ }
59
+ %ignore native_exception;
60
+ %inline {
54
61
  struct native_exception : public std::exception {
55
62
  #if defined(SWIGRUBY)
56
63
  int state;
@@ -61,16 +68,6 @@ struct native_exception : public std::exception {
61
68
  #endif
62
69
  };
63
70
  }
64
- %exception {
65
- try {
66
- $action
67
- } catch (const native_exception &e) {
68
- e.regenerate();
69
- SWIG_fail;
70
- } catch (const std::exception& e) {
71
- SWIG_exception_fail(SWIG_RuntimeError, e.what());
72
- }
73
- }
74
71
  #endif
75
72
 
76
73
  #ifdef SWIGRUBY
@@ -117,47 +114,82 @@ static std::string inspect_str(const VALUE &v){
117
114
  %import "SylphideMath.i"
118
115
  %import "Coordinate.i"
119
116
 
120
- %extend GPS_Time {
121
- %typemap(out) std::tm {
122
- %append_output(SWIG_From(int)($1.tm_year + 1900));
123
- %append_output(SWIG_From(int)($1.tm_mon + 1));
124
- %append_output(SWIG_From(int)($1.tm_mday));
125
- %append_output(SWIG_From(int)($1.tm_hour));
126
- %append_output(SWIG_From(int)($1.tm_min));
127
- %append_output(SWIG_From(int)($1.tm_sec));
117
+ %typemap(in,numinputs=0) const void *check_block {
118
+ #ifdef SWIGRUBY
119
+ if(!rb_block_given_p()){
120
+ return rb_enumeratorize(self, ID2SYM(rb_frame_callee()), argc, argv);
128
121
  }
129
- #if defined(SWIGRUBY)
130
- %typemap(in) const std::tm & (std::tm temp = {0}) {
131
- $1 = &temp;
132
- int *dst[] = {
133
- &(temp.tm_year),
134
- &(temp.tm_mon),
135
- &(temp.tm_mday),
136
- &(temp.tm_hour),
137
- &(temp.tm_min),
138
- &(temp.tm_sec),
139
- };
140
- int i_max(sizeof(dst) / sizeof(dst[0]));
141
- if(i_max > RARRAY_LEN($input)){i_max = RARRAY_LEN($input);}
122
+ #endif
123
+ }
124
+
125
+ %fragment(SWIG_From_frag(std::tm), "header", fragment=SWIG_From_frag(int)) {
126
+ SWIGINTERNINLINE SWIG_Object
127
+ SWIG_From_dec(std::tm)(const std::tm &value){
128
+ SWIG_Object res(SWIG_From(int)(value.tm_year + 1900));
129
+ res = SWIG_AppendOutput(res, SWIG_From(int)(value.tm_mon + 1));
130
+ res = SWIG_AppendOutput(res, SWIG_From(int)(value.tm_mday));
131
+ res = SWIG_AppendOutput(res, SWIG_From(int)(value.tm_hour));
132
+ res = SWIG_AppendOutput(res, SWIG_From(int)(value.tm_min));
133
+ return SWIG_AppendOutput(res, SWIG_From(int)(value.tm_sec));
134
+ }
135
+ }
136
+ %fragment(SWIG_AsVal_frag(std::tm), "header", fragment=SWIG_AsVal_frag(int)){
137
+ SWIGINTERN int
138
+ SWIG_AsVal_dec(std::tm)(SWIG_Object obj, std::tm *val) {
139
+ #ifdef SWIGRUBY
140
+ int *dst[] = {
141
+ &(val->tm_year),
142
+ &(val->tm_mon),
143
+ &(val->tm_mday),
144
+ &(val->tm_hour),
145
+ &(val->tm_min),
146
+ &(val->tm_sec),
147
+ };
148
+ if(RB_TYPE_P(obj, T_ARRAY)){
149
+ int i_max(RARRAY_LEN(obj));
150
+ if(i_max > sizeof(dst) / sizeof(dst[0])){return SWIG_ERROR;}
151
+ VALUE obj_i;
152
+ int v;
142
153
  for(int i(0); i < i_max; ++i){
143
- SWIG_Object obj = rb_ary_entry($input, i);
144
- int v;
145
- if(SWIG_IsOK(SWIG_AsVal(int)(obj, &v))){
146
- if(dst[i] == &(temp.tm_year)){
154
+ obj_i = RARRAY_AREF(obj, i);
155
+ if(SWIG_IsOK(SWIG_AsVal(int)(obj_i, &v))){
156
+ if(dst[i] == &(val->tm_year)){
147
157
  *dst[i] = v - 1900;
148
- }else if(dst[i] == &(temp.tm_mon)){
158
+ }else if(dst[i] == &(val->tm_mon)){
149
159
  *dst[i] = v - 1;
150
160
  }else{
151
161
  *dst[i] = v;
152
162
  }
153
163
  }else{
154
- SWIG_exception(SWIG_TypeError, "int is expected");
164
+ SWIG_exception(SWIG_TypeError,
165
+ std::string("Unexpected input [").append(std::to_string(i)).append("]: ")
166
+ .append(inspect_str(obj_i)).c_str());
155
167
  }
156
168
  }
169
+ return SWIG_OK;
157
170
  }
158
- %typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) const std::tm & {
159
- $1 = (TYPE($input) == T_ARRAY) ? 1 : 0;
171
+ #endif
172
+ return SWIG_ERROR;
173
+ }
174
+ }
175
+ %typemap(out, fragment=SWIG_From_frag(std::tm)) std::tm {
176
+ $result = SWIG_From(std::tm)($1);
177
+ }
178
+ %typemap(in, fragment=SWIG_AsVal_frag(std::tm)) const std::tm & (std::tm temp = {0}) {
179
+ if(SWIG_AsVal(std::tm)($input, $1 = &temp) != SWIG_OK){
180
+ SWIG_exception(SWIG_TypeError, "int[1..6] is expected");
160
181
  }
182
+ }
183
+ %typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) const std::tm & {
184
+ #ifdef SWIGRUBY
185
+ $1 = (TYPE($input) == T_ARRAY) ? 1 : 0;
186
+ #else
187
+ $1 = 0;
188
+ #endif
189
+ }
190
+
191
+ %extend GPS_Time {
192
+ #if defined(SWIGRUBY)
161
193
  %typemap(varout,fragment="SWIG_Traits_frag(FloatT)") leap_second_event_t [] {
162
194
  $result = rb_ary_new2(sizeof($1) / sizeof($1[0]));
163
195
  for(std::size_t i(0); i < sizeof($1) / sizeof($1[0]); ++i){
@@ -275,11 +307,12 @@ struct GPS_Ionospheric_UTC_Parameters : public GPS_SpaceNode<FloatT>::Ionospheri
275
307
  MAKE_ACCESSOR(WN_LSF, unsigned int);
276
308
  MAKE_ACCESSOR(DN, unsigned int);
277
309
  MAKE_ACCESSOR(delta_t_LSF, int);
310
+ %catches(std::invalid_argument) parse;
278
311
  static GPS_Ionospheric_UTC_Parameters<FloatT> parse(const unsigned int buf[10]){
279
312
  typedef typename GPS_SpaceNode<FloatT>
280
313
  ::BroadcastedMessage<unsigned int, 30> parser_t;
281
314
  if((parser_t::subframe_id(buf) != 4) || (parser_t::sv_page_id(buf) != 56)){
282
- throw std::runtime_error("Not valid data");
315
+ throw std::invalid_argument("Not valid data");
283
316
  }
284
317
  typename GPS_SpaceNode<FloatT>::Ionospheric_UTC_Parameters::raw_t raw;
285
318
  raw.update<2, 0>(buf);
@@ -894,11 +927,12 @@ struct GPS_User_PVT
894
927
  ERROR_VELOCITY_LS,
895
928
  };
896
929
  int error_code() const {return (int)(base_t::error_code);}
897
- const GPS_Time<FloatT> &receiver_time() const {return base_t::receiver_time;}
898
- const System_XYZ<FloatT, WGS84> &xyz() const {return base_t::user_position.xyz;}
899
- const System_LLH<FloatT, WGS84> &llh() const {return base_t::user_position.llh;}
930
+ // Returning Type because returning const Type & causes reference problem after GC
931
+ GPS_Time<FloatT> receiver_time() const {return base_t::receiver_time;}
932
+ System_XYZ<FloatT, WGS84> xyz() const {return base_t::user_position.xyz;}
933
+ System_LLH<FloatT, WGS84> llh() const {return base_t::user_position.llh;}
900
934
  const FloatT &receiver_error() const {return base_t::receiver_error;}
901
- const System_ENU<FloatT, WGS84> &velocity() const {return base_t::user_velocity_enu;}
935
+ System_ENU<FloatT, WGS84> velocity() const {return base_t::user_velocity_enu;}
902
936
  const FloatT &receiver_error_rate() const {return base_t::receiver_error_rate;}
903
937
  const FloatT &gdop() const {return base_t::dop.g;}
904
938
  const FloatT &pdop() const {return base_t::dop.p;}
@@ -975,23 +1009,9 @@ struct GPS_User_PVT
975
1009
  %extend GPS_Measurement {
976
1010
  %ignore items_t;
977
1011
  %ignore items;
978
- %exception each {
979
- #ifdef SWIGRUBY
980
- if(!rb_block_given_p()){
981
- return rb_enumeratorize(self, ID2SYM(rb_intern("each")), argc, argv);
982
- }
983
- #endif
984
- try {
985
- $action
986
- } catch (const native_exception &e) {
987
- e.regenerate();
988
- SWIG_fail;
989
- } catch (const std::exception& e) {
990
- SWIG_exception_fail(SWIG_RuntimeError, e.what());
991
- }
992
- }
993
1012
  %fragment(SWIG_Traits_frag(FloatT));
994
- void each() const {
1013
+ %catches(native_exception) each;
1014
+ void each(const void *check_block) const {
995
1015
  for(typename GPS_Measurement<FloatT>::items_t::const_iterator
996
1016
  it(self->items.begin()), it_end(self->items.end());
997
1017
  it != it_end; ++it){
@@ -1074,18 +1094,18 @@ struct GPS_User_PVT
1074
1094
  .append(inspect_str(v_key_value)).append("}").c_str());
1075
1095
  }
1076
1096
  rb_hash_foreach(v_key_value,
1077
- #if RUBY_API_VERSION < 20700
1097
+ %#if RUBY_API_VERSION_CODE < 20700
1078
1098
  // @see https://docs.ruby-lang.org/ja/latest/doc/news=2f2_7_0.html
1079
1099
  (int (*)(ANYARGS))
1080
- #endif
1100
+ %#endif
1081
1101
  arg_t::iter2, v_arg);
1082
1102
  return ST_CONTINUE;
1083
1103
  }
1084
1104
  } arg = {val};
1085
1105
  rb_hash_foreach(obj,
1086
- #if RUBY_API_VERSION < 20700
1106
+ %#if RUBY_API_VERSION_CODE < 20700
1087
1107
  (int (*)(ANYARGS))
1088
- #endif
1108
+ %#endif
1089
1109
  arg_t::iter1, reinterpret_cast<VALUE>(&arg));
1090
1110
  return SWIG_OK;
1091
1111
  }
@@ -1149,6 +1169,7 @@ struct GPS_Measurement {
1149
1169
  L1_RANGE_RATE_SIGMA,
1150
1170
  L1_SIGNAL_STRENGTH_dBHz,
1151
1171
  L1_LOCK_SEC,
1172
+ L1_CARRIER_PHASE_AMBIGUITY_SCALE,
1152
1173
  L1_FREQUENCY,
1153
1174
  #define make_entry(key) L2CM_ ## key, L2CL_ ## key
1154
1175
  #define make_entry2(key) make_entry(key), make_entry(key ## _SIGMA)
@@ -1158,6 +1179,7 @@ struct GPS_Measurement {
1158
1179
  make_entry2(RANGE_RATE),
1159
1180
  make_entry(SIGNAL_STRENGTH_dBHz),
1160
1181
  make_entry(LOCK_SEC),
1182
+ make_entry(CARRIER_PHASE_AMBIGUITY_SCALE),
1161
1183
  #undef make_entry2
1162
1184
  #undef make_entry
1163
1185
  ITEMS_PREDEFINED,
@@ -1322,6 +1344,7 @@ struct HookableSolver : public BaseT {
1322
1344
  %ignore user_correctors;
1323
1345
  %immutable hooks;
1324
1346
  %ignore mark;
1347
+ %catches(native_exception, std::runtime_error) solve;
1325
1348
  %fragment("hook"{GPS_Solver<FloatT>}, "header",
1326
1349
  fragment=SWIG_From_frag(int),
1327
1350
  fragment=SWIG_Traits_frag(FloatT),
@@ -1385,7 +1408,7 @@ struct HookableSolver : public BaseT {
1385
1408
  if((!RB_TYPE_P(res_hook, T_ARRAY))
1386
1409
  || (RARRAY_LEN(res_hook) != prop_items)){
1387
1410
  throw std::runtime_error(
1388
- std::string("[d * ").append(std::to_string(prop_items))
1411
+ std::string("relative_property() returning [d * ").append(std::to_string(prop_items))
1389
1412
  .append("] is expected (d: " %str(FloatT) "), however ")
1390
1413
  .append(inspect_str(res_hook)));
1391
1414
  }
@@ -1393,7 +1416,7 @@ struct HookableSolver : public BaseT {
1393
1416
  VALUE v(RARRAY_AREF(res_hook, i));
1394
1417
  if(!SWIG_IsOK(swig::asval(v, &res.values[i]))){
1395
1418
  throw std::runtime_error(
1396
- std::string(%str(FloatT) " is exepcted, however ")
1419
+ std::string("relative_property() returning " %str(FloatT) " is exepcted, however ")
1397
1420
  .append(inspect_str(v))
1398
1421
  .append(" @ [").append(std::to_string(i)).append("]"));
1399
1422
  }
@@ -1516,7 +1539,7 @@ struct HookableSolver : public BaseT {
1516
1539
  list_t input;
1517
1540
  if(update){
1518
1541
  if(!RB_TYPE_P(hash, T_HASH)){
1519
- throw std::runtime_error(
1542
+ throw std::invalid_argument(
1520
1543
  std::string("Hash is expected, however ").append(inspect_str(hash)));
1521
1544
  }
1522
1545
  for(std::size_t i(0); i < sizeof(k_root) / sizeof(k_root[0]); ++i){
@@ -1594,6 +1617,7 @@ struct HookableSolver : public BaseT {
1594
1617
  VALUE get_correction() const {
1595
1618
  return const_cast<GPS_Solver<FloatT> *>(self)->update_correction(false, Qnil);
1596
1619
  }
1620
+ %catches(std::invalid_argument) set_correction;
1597
1621
  VALUE set_correction(VALUE hash){
1598
1622
  return self->update_correction(true, hash);
1599
1623
  }
@@ -1824,23 +1848,9 @@ struct GPS_Solver
1824
1848
  %fragment(SWIG_From_frag(char));
1825
1849
 
1826
1850
  %extend RINEX_Observation {
1827
- %exception read {
1828
- #ifdef SWIGRUBY
1829
- if(!rb_block_given_p()){
1830
- return rb_enumeratorize(self, ID2SYM(rb_intern("read")), argc, argv);
1831
- }
1832
- #endif
1833
- try {
1834
- $action
1835
- } catch (const native_exception &e) {
1836
- e.regenerate();
1837
- SWIG_fail;
1838
- } catch (const std::exception& e) {
1839
- SWIG_exception_fail(SWIG_RuntimeError, e.what());
1840
- }
1841
- }
1842
1851
  %fragment(SWIG_Traits_frag(FloatT));
1843
- static void read(const char *fname) {
1852
+ %catches(native_exception) read;
1853
+ static void read(const char *fname, const void *check_block) {
1844
1854
  std::fstream fin(fname, std::ios::in | std::ios::binary);
1845
1855
  struct reader_t : public RINEX_OBS_Reader<FloatT> {
1846
1856
  typedef RINEX_OBS_Reader<FloatT> super_t;