Comments (10)
@Inrixia Thanks for bringing this up.
everything while properties like speed/lat/lon etc should all be floats.
This is right and should be fixed. Seems like artifacts from copy and pasting :-D
Also shouldn't the defaults be None for missing values, or am I misinterpreting what the default property represents?
These default values (e.g. default=0
) are only used when encoding. This is done, so that the user does not have to pass all values, but only a few. When decoding these values are never used. For each field of the message there are only two cases:
- the message is long enough to contain the field -> the bitarray is converted to the value
- the message is too short for the field -> the field is None
from pyais.
Sounds good, what branch can I install to test?
The main cause of this issue being opened was tons of reports having 0 instead of 0.0 which caused typing issues with stuff further down the pipeline, so want to check if that's fixed with your changes.
from pyais.
Sounds good, what branch can I install to test?
There is no branch yet 😀
from pyais.
Now there is a branch: #57
@Inrixia Do you want to try it out?
from pyais.
Hey, sorry for the delay in replying. Have tried out the changes and looks promising. There a bunch of comments on the PR highlighting some more issues though.
StructType([
StructField('validChecksum', BooleanType()),
StructField('NMEATalker', StringType()),
StructField('NMEAType', StringType()),
StructField('frag_cnt', IntegerType()),
StructField('frag_num', IntegerType()),
StructField('seq_id', IntegerType()),
StructField('channel', StringType()),
StructField('decodingError', StringType()),
StructField('msg_type', IntegerType()),
StructField('repeat', IntegerType()),
StructField('mmsi', StringType()),
StructField('speed', FloatType()),
StructField('accuracy', BooleanType()),
StructField('course', FloatType()),
StructField('lon', FloatType()),
StructField('lat', FloatType()),
StructField('heading', IntegerType()),
StructField('second', IntegerType()),
StructField('regional', IntegerType()),
StructField('cs', BooleanType()),
StructField('display', BooleanType()),
StructField('dsc', BooleanType()),
StructField('band', BooleanType()),
StructField('msg22', BooleanType()),
StructField('assigned', BooleanType()),
StructField('raim', BooleanType()),
StructField('radio', IntegerType()),
StructField('status', IntegerType()),
StructField('turn', IntegerType()),
StructField('maneuver', IntegerType()),
StructField('aid_type', IntegerType()),
StructField('name', StringType()),
StructField('to_bow', IntegerType()),
StructField('to_stern', IntegerType()),
StructField('to_port', IntegerType()),
StructField('to_starboard', IntegerType()),
StructField('epfd', IntegerType()),
StructField('off_position', BooleanType()),
StructField('virtual_aid', BooleanType()),
StructField('name_ext', StringType()),
StructField('dac', IntegerType()),
StructField('fid', IntegerType()),
StructField('data', StringType()),
StructField('year', IntegerType()),
StructField('month', IntegerType()),
StructField('day', IntegerType()),
StructField('hour', IntegerType()),
StructField('minute', IntegerType()),
StructField('partno', IntegerType()),
StructField('shipname', StringType()),
StructField('vendorid', StringType()),
StructField('model', IntegerType()),
StructField('serial', IntegerType()),
StructField('callsign', StringType()),
StructField('mothership_mmsi', StringType()),
StructField('seqno', IntegerType()),
StructField('dest_mmsi', StringType()),
StructField('retransmit', BooleanType()),
StructField('ais_version', IntegerType()),
StructField('imo', IntegerType()),
StructField('draught', FloatType()),
StructField('destination', StringType()),
StructField('dte', BooleanType()),
StructField('offset1', IntegerType()),
StructField('number1', IntegerType()),
StructField('timeout1', IntegerType()),
StructField('increment1', IntegerType()),
StructField('offset2', IntegerType()),
StructField('number2', IntegerType()),
StructField('timeout2', IntegerType()),
StructField('increment2', IntegerType()),
StructField('offset3', IntegerType()),
StructField('number3', IntegerType()),
StructField('timeout3', IntegerType()),
StructField('increment3', IntegerType()),
StructField('offset4', IntegerType()),
StructField('number4', IntegerType()),
StructField('timeout4', IntegerType()),
StructField('increment4', IntegerType()),
StructField('addressed', BooleanType()),
StructField('structured', BooleanType()),
StructField('text', StringType()),
StructField('mmsi1', StringType()),
StructField('type1_1', IntegerType()),
StructField('offset1_1', IntegerType()),
StructField('type1_2', IntegerType()),
StructField('offset1_2', IntegerType()),
StructField('mmsi2', StringType()),
StructField('type2_1', IntegerType()),
StructField('offset2_1', IntegerType()),
StructField('gnss', BooleanType()),
StructField('mmsiseq1', IntegerType()),
StructField('mmsiseq2', IntegerType()),
StructField('mmsi3', StringType()),
StructField('mmsiseq3', IntegerType()),
StructField('mmsi4', StringType()),
StructField('mmsiseq4', IntegerType()),
StructField('app_id', IntegerType()),
StructField('alt', IntegerType()),
StructField('channel_a', IntegerType()),
StructField('channel_b', IntegerType()),
StructField('txrx', IntegerType()),
StructField('power', BooleanType()),
StructField('band_a', BooleanType()),
StructField('band_b', BooleanType()),
StructField('zonesize', IntegerType()),
StructField('ne_lon', FloatType()),
StructField('ne_lat', FloatType()),
StructField('sw_lon', FloatType()),
StructField('sw_lat', FloatType()),
StructField('station_type', IntegerType()),
StructField('ship_type', IntegerType()),
StructField('interval', IntegerType()),
StructField('quiet', IntegerType())
])
This is the current schema I have for all possible fields the library can return, is it accurate? Looking at the number of potential errors and gotchas I think it is probably a good idea to nail down the expected types for all fields so they can be properly enforced.
from pyais.
Hey @Inrixia,
There a bunch of comments on the PR highlighting some more issues though.
Most of them seemed to be incorrect, because the user did not look into the spec closely enough.
Looking at the number of potential errors and gotchas I think it is probably a good idea to nail down the expected types for all fields so they can be properly enforced.
I went across all types and compared their type to the specification I found on https://gpsd.gitlab.io/g. I am pretty sure, that we found most of the issues.
from pyais.
I got this output for all types:
{'accuracy': <class 'int'>,
'aid_type': <class 'int'>,
'ais_version': <class 'int'>,
'alt': <class 'int'>,
'assigned': <class 'bool'>,
'band': <class 'bool'>,
'callsign': <class 'str'>,
'course': <class 'float'>,
'cs': <class 'bool'>,
'dac': <class 'int'>,
'data': <class 'int'>,
'day': <class 'int'>,
'dest_mmsi': <class 'int'>,
'destination': <class 'str'>,
'display': <class 'bool'>,
'draught': <class 'float'>,
'dsc': <class 'bool'>,
'dte': <class 'bool'>,
'epfd': <class 'int'>,
'fid': <class 'int'>,
'gnss': <class 'int'>,
'heading': <class 'int'>,
'hour': <class 'int'>,
'imo': <class 'int'>,
'increment1': <class 'int'>,
'increment2': <class 'int'>,
'increment3': <class 'int'>,
'increment4': <class 'int'>,
'interval': <class 'int'>,
'lat': <class 'float'>,
'lon': <class 'float'>,
'maneuver': <class 'int'>,
'minute': <class 'int'>,
'mmsi': <class 'int'>,
'mmsi1': <class 'int'>,
'mmsi2': <class 'int'>,
'mmsi3': <class 'int'>,
'mmsi4': <class 'int'>,
'mmsiseq1': <class 'int'>,
'mmsiseq2': <class 'int'>,
'mmsiseq3': <class 'int'>,
'mmsiseq4': <class 'int'>,
'month': <class 'int'>,
'msg22': <class 'bool'>,
'msg_type': <class 'int'>,
'name': <class 'str'>,
'name_ext': <class 'str'>,
'ne_lat': <class 'int'>,
'ne_lon': <class 'int'>,
'number1': <class 'int'>,
'number2': <class 'int'>,
'number3': <class 'int'>,
'number4': <class 'int'>,
'off_position': <class 'bool'>,
'offset1': <class 'int'>,
'offset1_1': <class 'int'>,
'offset1_2': <class 'int'>,
'offset2': <class 'int'>,
'offset2_1': <class 'int'>,
'offset3': <class 'int'>,
'offset4': <class 'int'>,
'quiet': <class 'int'>,
'radio': <class 'int'>,
'raim': <class 'bool'>,
'regional': <class 'int'>,
'repeat': <class 'int'>,
'reserved': <class 'int'>,
'reserved_2': <class 'int'>,
'retransmit': <class 'bool'>,
'second': <class 'int'>,
'seqno': <class 'int'>,
'ship_type': <class 'int'>,
'shipname': <class 'str'>,
'spare': <class 'int'>,
'spare_1': <class 'int'>,
'spare_2': <class 'int'>,
'spare_3': <class 'int'>,
'spare_4': <class 'int'>,
'speed': <class 'float'>,
'station_type': <class 'int'>,
'status': <class 'int'>,
'sw_lat': <class 'int'>,
'sw_lon': <class 'int'>,
'text': <class 'str'>,
'timeout1': <class 'int'>,
'timeout2': <class 'int'>,
'timeout3': <class 'int'>,
'timeout4': <class 'int'>,
'to_bow': <class 'int'>,
'to_port': <class 'int'>,
'to_starboard': <class 'int'>,
'to_stern': <class 'int'>,
'turn': <class 'int'>,
'txrx': <class 'int'>,
'type1_1': <class 'int'>,
'type1_2': <class 'int'>,
'type2_1': <class 'int'>,
'virtual_aid': <class 'bool'>,
'year': <class 'int'>}
from pyais.
I also added a unittest that make sure that the types are identical for all messages:
Line 932 in 5e0d5fb
from pyais.
Released with v2.0.3.
https://github.com/M0r13n/pyais/releases/tag/v2.0.3
from pyais.
Will check it out, thanks again for the update
from pyais.
Related Issues (20)
- [docs] messages.rst content duplicated. HOT 1
- PiPY out of date? HOT 1
- Stream from serial/COM port HOT 2
- lat lon converters float accuracy HOT 2
- AtoN codes do not match R0126 (A-126) Table 3 or M.1371-5 TABLE 74 HOT 1
- Provide decoding of communication status field in types 1, 2, 3, 4, 9, 11, 18 HOT 5
- pyais fails to decode type 5 messages HOT 6
- Message Type 26 Logic may be incorrect HOT 2
- MessageType24PartA : incorrect length? HOT 6
- EpfdType Enum Missing InternalGNSS = 15 HOT 2
- Navigational statuses 9, 10, 13 and Ship type 29 HOT 3
- NoneFilter broken HOT 1
- Get Country Code HOT 5
- TCPConnection stops receiving messages HOT 4
- Determination of the communication status field HOT 5
- Encoded NRZI data HOT 1
- Timestamp for message type 1 and others HOT 1
- TypeError: 'dict' object is not callable HOT 2
- Gatehouse wrapper messages feature HOT 8
- Variable-width text fields processed as constant-width ones HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyais.