schwehr / libais

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

Parsers don't cast values to Python types #123

Closed geowurster closed 8 years ago

geowurster commented 8 years ago

ais.tag_block.Parse() and ais.vdm.Parse() return dictionaries with some keys that should be cast to int and float. For example, result from ais.vdm.Parse():

{
    "body": "15SimR001Q6jmk9pwgp<Rr1n06sd",
    "chan": "A",
    "checksum": "66",
    "fill_bits": "0",
    "sen_num": "1",
    "sen_tot": "1",
    "seq_id": null,
    "talker": "AI",
    "vdm": "!AIVDM,1,1,,A,15SimR001Q6jmk9pwgp<Rr1n06sd,0*66",
    "vdm_type": "VDM"
}

All numeric values except checksum should be converted to the appropriate Python type with ais.util.MaybeToNumber(). Additionally, MaybeToNumber() should probably add NoneType to the isinsance() checks at the top.

@schwehr I can take care of this.