schwehr / libais

C++ decoder for Automatic Identification System for tracking ships and decoding maritime information
Other
215 stars 94 forks source link

"currents" list attached in wrong place #229

Open andyvan-trabus opened 2 years ago

andyvan-trabus commented 2 years ago

I see the following code in ais_py.cpp:

case AIS8_1_26_SENSOR_CURR_2D: { Ais8_1_26_Curr2D rpt = reinterpret_cast<Ais8_1_26_Curr2D >(msg.reports[rpt_num]); DictSafeSetItem(rpt_dict, "type", rpt->type); DictSafeSetItem(rpt_dict, "spare", rpt->spare);

    PyObject *curr_list = PyList_New(3);
    DictSafeSetItem(dict, "currents", curr_list);
    for (size_t idx = 0; idx < 3; idx++) {
      PyObject *curr_dict = PyDict_New();
      DictSafeSetItem(curr_dict, "speed", rpt->currents[idx].speed);
      DictSafeSetItem(curr_dict, "dir", rpt->currents[idx].dir);
      DictSafeSetItem(curr_dict, "depth", rpt->currents[idx].depth);
      PyList_SetItem(curr_list, idx, curr_dict);
    }
  }
  break;

The DictSafeSetItem call for "currents" should be specifying rpt as the first parameter, not dict. This same problem is present in the code for AIS8_1_26_SENSOR_HORZ_FLOW and AIS8_1_26_SENSOR_CURR_3D.