From a618234ce7d5aa9f6c28dd686b36f705bdd3e04b Mon Sep 17 00:00:00 2001 From: Dimitrios Pallas Date: Thu, 29 Jun 2023 19:30:20 +0300 Subject: [PATCH] fixed rate of turn --- ais-lib-cli/pom.xml | 2 +- ais-lib-communication/pom.xml | 2 +- ais-lib-json/pom.xml | 2 +- .../AisPositionMessageDecoderTest.java | 2 +- ais-lib-messages/pom.xml | 2 +- .../java/dk/dma/ais/message/AisPositionMessage.java | 13 ++++++++++++- .../test/java/dk/dma/ais/sentence/MessageTest.java | 2 +- ais-lib-utils/pom.xml | 2 +- pom.xml | 2 +- 9 files changed, 20 insertions(+), 9 deletions(-) diff --git a/ais-lib-cli/pom.xml b/ais-lib-cli/pom.xml index 2f2721b3..52dc1aee 100644 --- a/ais-lib-cli/pom.xml +++ b/ais-lib-cli/pom.xml @@ -4,7 +4,7 @@ dk.dma.ais.lib ais-parent - 2.8.1 + 2.8.2 diff --git a/ais-lib-communication/pom.xml b/ais-lib-communication/pom.xml index 5d012848..cbeaf5f2 100755 --- a/ais-lib-communication/pom.xml +++ b/ais-lib-communication/pom.xml @@ -5,7 +5,7 @@ dk.dma.ais.lib ais-parent - 2.8.1 + 2.8.2 ../pom.xml diff --git a/ais-lib-json/pom.xml b/ais-lib-json/pom.xml index 0abb4f6a..647fa30c 100644 --- a/ais-lib-json/pom.xml +++ b/ais-lib-json/pom.xml @@ -5,7 +5,7 @@ dk.dma.ais.lib ais-parent - 2.8.1 + 2.8.2 ../pom.xml diff --git a/ais-lib-json/src/test/java/dk/dma/ais/message_decoders/AisPositionMessageDecoderTest.java b/ais-lib-json/src/test/java/dk/dma/ais/message_decoders/AisPositionMessageDecoderTest.java index 534a76ac..1b6c9b7a 100644 --- a/ais-lib-json/src/test/java/dk/dma/ais/message_decoders/AisPositionMessageDecoderTest.java +++ b/ais-lib-json/src/test/java/dk/dma/ais/message_decoders/AisPositionMessageDecoderTest.java @@ -56,7 +56,7 @@ public void shouldWork() throws AisMessageException, SixbitException, SentenceEx JSONAssert.assertEquals( DecoderTestHelper.getJson(objectWriter, - new DecodedAisFieldObject(0, "Turning right at 0.0 degrees/ min")).toString(), + new DecodedAisFieldObject(-1, "Turning left at 0.04464028833340796 degrees/ min")).toString(), jsonObject.get("rotDFO").toString(), true); diff --git a/ais-lib-messages/pom.xml b/ais-lib-messages/pom.xml index 1dcef72c..ed6f4929 100755 --- a/ais-lib-messages/pom.xml +++ b/ais-lib-messages/pom.xml @@ -5,7 +5,7 @@ dk.dma.ais.lib ais-parent - 2.8.1 + 2.8.2 ../pom.xml diff --git a/ais-lib-messages/src/main/java/dk/dma/ais/message/AisPositionMessage.java b/ais-lib-messages/src/main/java/dk/dma/ais/message/AisPositionMessage.java index e2bda587..f1b1f377 100644 --- a/ais-lib-messages/src/main/java/dk/dma/ais/message/AisPositionMessage.java +++ b/ais-lib-messages/src/main/java/dk/dma/ais/message/AisPositionMessage.java @@ -252,9 +252,20 @@ public void setNavStatus(int navStatus) { * @return the rot */ public int getRot() { - return rot; + if (rot == 128) { + return 0; + } + int signedRot = (byte) rot; + double sensorRot = Math.pow(signedRot / 4.733, 2); + if (signedRot < 0) { + sensorRot *= -1; + return (int) sensorRot + 1; + } else { + return (int) sensorRot - 1; + } } + /** * Gets sensor rot. * diff --git a/ais-lib-messages/src/test/java/dk/dma/ais/sentence/MessageTest.java b/ais-lib-messages/src/test/java/dk/dma/ais/sentence/MessageTest.java index 7f30869d..eafa9321 100644 --- a/ais-lib-messages/src/test/java/dk/dma/ais/sentence/MessageTest.java +++ b/ais-lib-messages/src/test/java/dk/dma/ais/sentence/MessageTest.java @@ -44,7 +44,7 @@ public void testMessage1() throws SentenceException, SixbitException, AisMessage Assert.assertEquals("repeat", 0, msg.getRepeat()); Assert.assertEquals("userid", 636012431, msg.getUserId()); Assert.assertEquals("nav_status", 8, msg.getNavStatus()); - Assert.assertEquals("rot", 0, msg.getRot()); + Assert.assertEquals("rot", -1, msg.getRot()); Assert.assertEquals("sog", 191, msg.getSog()); Assert.assertEquals("pos_acc", 1, msg.getPosAcc()); Assert.assertEquals("longitude", -73481550, msg.getPos().getLongitude()); diff --git a/ais-lib-utils/pom.xml b/ais-lib-utils/pom.xml index 34fb8bbb..6eb833d8 100644 --- a/ais-lib-utils/pom.xml +++ b/ais-lib-utils/pom.xml @@ -5,7 +5,7 @@ dk.dma.ais.lib ais-parent - 2.8.1 + 2.8.2 ../pom.xml diff --git a/pom.xml b/pom.xml index c510496d..d2dab169 100755 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ dk.dma.ais.lib ais-parent - 2.8.1 + 2.8.2 AIS Parent pom This parent pom for AIS