nsnw / aprspy

An APRS packet parser for Python
MIT License
13 stars 0 forks source link

Degrees fields not being zerofilled when generating a PositionPacket #10

Closed TomMladenov closed 3 years ago

TomMladenov commented 3 years ago

When generating a PositionPacket with: compressed = False, source="RS41", destination="BASE", lat=50.99263, lon=4.79026, ambiguity=0, symbol_table="/", symbol_id="O", path=''WIDE2-2"

after calling .generate() the following packet is created: "RS41>BASE,WIDE2-2:!5059.56N/447.42EO"

which is not conform to the standard for the longitude field in this case, there should be 2 extra leading zeros. The degrees field of both the latitude and longitude should be zfilled to lengths 2 and 3 respectively. Adding .zfill(2) and .zfill(3) operators for latitude and longitude degrees field when applying the ambiguity makes the packets conform again to the standard.

Resulting packet after adding .zfill(3) for the degrees field of the longitude in function def encode_uncompressed_latitude(latitude: Union[float, int], ambiguity: int = 0): "RS41>BASE,WIDE2-2:!5059.56N/00447.42EO"

nsnw commented 3 years ago

Hi Tom! Thanks for the report, and apologies it took a few days for me to look at it.

I'm about to commit the fix, which should now make it return properly-padded degrees of latitude and longitude.