eburrows / aislib

Java AIS library and utilities
http://www.erikburrows.com/index.php?node=AISlib
GNU General Public License v2.0
1 stars 1 forks source link

courseOverGround incorrect #2

Open philci52 opened 12 years ago

philci52 commented 12 years ago

I'm using aislib to parse some AIS messages and noticed that the value that is returned for courseOverGround in messages 1,2,3 is incorrect. The values should be between 0-360, but I'm getting negative values:

!AIVDM,1,1,,B,142LTc@vAd0FpS@E?KQ::82V0<0:,0*55

{longitude=4.999, positionAccuracy=0, navigationalStatus=0, rateOfTurn=249, repeat=0, maneuver=0, UTC=19, messageType=1, courseOverGround=-149.6, trueHeading=257, speedOverGround=108, sourceMmsi=271000749, latitude=37.1215, spare=0, communicationStatus=49162, raimFlag=0}

However, if I use this site http://rl.se/aivdm

I get these results, which make much more sense:

of ships in range: 10

MMSI : 271000749 Latitude : 37.121500° Longitude : 4.999000° Speed : 10.8 knots Heading : 257° Course over ground : 260° Rate of turn : -2°/min Navigational status: 0 Nearest place : Bejaïa, Algeria

philci52 commented 12 years ago

NOTE from this site: http://gpsd.berlios.de/AIVDM.html

Both speedOverGround and courseOverGround are of the same type (U1), but the Patterns.java lists them as different types and in fact, neither do what I would really want, which is to get a (correct) floating point number back.

philci52 commented 12 years ago

I've posted the files that I updated to fix this issue. Its not a comprehensive fix and it does change the type for the speedOverGround value, but it works. GitHub sucks for attaching files to issues.

https://gist.github.com/2319476

Basically I created a new type called ufloat (unsigned float) and the the corresponding function to grab one.