Skip to content

Commit

Permalink
Refactor/ais interfaces (#133)
Browse files Browse the repository at this point in the history
* Use longitude meta field to check longitude value availability in position report type B
* Expose AISPositionInfo to allow users to access basic position information more easily
* Refactor AIS position report interfaces, AISPositionReport now extends AISPositionReportB.
  • Loading branch information
alexismanin authored Feb 5, 2022
1 parent 41f8da2 commit be6ca8b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* @author Lázár József
*/
interface AISPositionInfo extends AISMessage {
public interface AISPositionInfo extends AISMessage {

/**
* Tells if the position is accurate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@
* See <a href="https://www.navcen.uscg.gov/?pageName=AISMessagesA">Class A AIS
* position report</a> specification for more details on return values and
* status codes.</p>
*
* @author Lázár József
*/
public interface AISPositionReport extends AISPositionInfo {
public interface AISPositionReport extends AISPositionReportB {

/**
* Returns the navigational status.
Expand All @@ -46,40 +45,6 @@ public interface AISPositionReport extends AISPositionInfo {
*/
double getRateOfTurn();

/**
* Returns the speed over ground. Notice that maximum returned speed is
* 102.2, even when the actual speed is higher.
*
* @return Speed in knots 0-102.2 or 102.3 when not available.
*/
double getSpeedOverGround();

/**
* Returns the course over ground.
*
* @return Course in degrees 0-359.9 or 360 when not available (default).
*/
double getCourseOverGround();

/**
* Returns the true heading.
*
* @return Heading in degrees 0-359 or 511 when not available (default).
*/
int getTrueHeading();

/**
* Returns the time stamp contained in the message, i.e. UTC second when the
* report was generated by the electronic position system.
*
* @return 0-59 or 60 if time stamp is not available, which should also be
* the default value. 61 if positioning system is in manual input
* mode, or 62 if electronic position fixing system operates in
* estimated (dead reckoning) mode, or 63 if the positioning system
* is inoperative.
*/
int getTimeStamp();

/**
* Returns the manouver indicator.
*
Expand All @@ -94,32 +59,4 @@ public interface AISPositionReport extends AISPositionInfo {
* @return true if has ROT, otherwise false.
*/
boolean hasRateOfTurn();

/**
* Returns true if speed over ground is available in the message.
*
* @return true if has SOG, otherwise false.
*/
boolean hasSpeedOverGround();

/**
* Returns true if course over ground is available in the message.
*
* @return true if has COG, otherwise false.
*/
boolean hasCourseOverGround();

/**
* Returns true if true heading is available in the message.
*
* @return true if has true heading, otherwise false.
*/
boolean hasTrueHeading();

/**
* Returns true if timestamp is available in the message.
*
* @return true if has time stamp, otherwise false.
*/
boolean hasTimeStamp();
}
22 changes: 12 additions & 10 deletions src/main/java/net/sf/marineapi/ais/message/AISPositionReportB.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,36 @@
public interface AISPositionReportB extends AISPositionInfo {

/**
* Returns the speed over ground.
* Returns the speed over ground. Notice that maximum returned speed is
* 102.2, even when the actual speed is higher.
*
* @return Speed over ground
* @return Speed in knots 0-102.2 or 102.3 when not available.
*/
double getSpeedOverGround();

/**
* Returns the course over ground.
*
* @return Course over ground
* @return Course in degrees 0-359.9 or 360 when not available (default).
*/
double getCourseOverGround();

/**
* Returns the true heading.
*
* @return true heading value, in degrees
* @return Heading in degrees 0-359 or 511 when not available (default).
*/
int getTrueHeading();

/**
* Returns the message time stamp. UTC second when the report was generated
* by the EPFS (0-59). 60 if time stamp is not available, which should also
* be the default value. 61 if positioning system is in manual input mode.
* 62 if electronic position fixing system operates in estimated (dead
* reckoning) mode. 63 if the positioning system is inoperative.
* Returns the time stamp contained in the message, i.e. UTC second when the
* report was generated by the electronic position system.
*
* @return Timestamp value
* @return 0-59 or 60 if time stamp is not available, which should also be
* the default value. 61 if positioning system is in manual input
* mode, or 62 if electronic position fixing system operates in
* estimated (dead reckoning) mode, or 63 if the positioning system
* is inoperative.
*/
int getTimeStamp();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public boolean hasTimeStamp() {

@Override
public boolean hasLongitude() {
return Latitude27.isAvailable(fLongitude);
return Longitude28.isAvailable(fLongitude);
}

@Override
Expand Down

0 comments on commit be6ca8b

Please sign in to comment.