Skip to content

Commit

Permalink
Fixed horizontal containment radius limit in surface position (#23)
Browse files Browse the repository at this point in the history
Removed wrong cast to byte
  • Loading branch information
fixje committed Aug 5, 2024
1 parent ad450d9 commit 3654614
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public double getHorizontalContainmentRadiusLimit() {
case 5: return 7.5;
case 6: return 25;
case 7:
return (byte) (hasNICSupplementA() ? 75 : 185.2);
return hasNICSupplementA() ? 75 : 185.2;
case 8:
if (hasNICSupplementC() && hasNICSupplementA())
return 370.4;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package de.serosystems.lib1090.msgs.adsb;

import de.serosystems.lib1090.Position;
import de.serosystems.lib1090.exceptions.BadFormatException;
import de.serosystems.lib1090.exceptions.UnspecifiedFormatError;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

class SurfacePositionV2MsgTest {

// A surface position report observed in the wild, decomposed by single bits
public static final String SURF_POS =
"8c" +

// ICAO 24 bit address
"3c4dc6" +

// 00111 => type code 7
// 0000001 => Movement
// 1 => Heading/Ground Track Status
// 1000000 => Heading/Ground Track
// 0 => Time
// 1 => CPR format
// 11001100110001101 => CPR lat
// 10000001010011110 => CPT lon
"381c07331b029e" +

// parity bits (valid, not tested here)
"b308de";

@Test
void testDecodeSurfacePosition() throws BadFormatException, UnspecifiedFormatError {
final SurfacePositionV2Msg sPos = new SurfacePositionV2Msg(SURF_POS, null);

assertEquals(2, sPos.getSIL());
assertTrue(sPos.hasGroundSpeed());
assertEquals(0, sPos.getGroundSpeed());
assertEquals(0.125, sPos.getGroundSpeedResolution());
assertTrue(sPos.hasValidHeading());
assertEquals(64*360D/128D, sPos.getHeading());
assertFalse(sPos.hasTimeFlag());
assertTrue(sPos.hasValidPosition());
assertEquals(0, sPos.getAltitude());
assertEquals(Position.AltitudeType.ABOVE_GROUND_LEVEL, sPos.getAltitudeType());
}

@Test
void testGetNIC() throws BadFormatException, UnspecifiedFormatError {
final SurfacePositionV2Msg sPos = new SurfacePositionV2Msg(SURF_POS, null);

assertEquals(8, sPos.getNIC());
}

@Test
void testGetNICWithSupplementA() throws BadFormatException, UnspecifiedFormatError {
final SurfacePositionV2Msg sPos = new SurfacePositionV2Msg(SURF_POS, null);
sPos.setNICSupplementA(true);

assertEquals(9, sPos.getNIC());
}

@Test
void testGetHorizontalContainmentRadiusLimit() throws BadFormatException, UnspecifiedFormatError {
final SurfacePositionV2Msg sPos = new SurfacePositionV2Msg(SURF_POS, null);

assertEquals(185.2, sPos.getHorizontalContainmentRadiusLimit());
}

@Test
void testGetHorizontalContainmentRadiusLimitWithSupplementA() throws BadFormatException, UnspecifiedFormatError {
final SurfacePositionV2Msg sPos = new SurfacePositionV2Msg(SURF_POS, null);
sPos.setNICSupplementA(true);

assertEquals(75, sPos.getHorizontalContainmentRadiusLimit());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class TargetStateAndStatusMsgTest {
// A TSS report observed in reality, decomposed by single bits
public static final String TSS_WITHOUT_HEADING =
// 10001 => DF 17
// 101 => FF (firs field, node needed here)
// 101 => FF (first field, not needed here)
"8d" +

// ICAO 24 bit address
Expand Down

0 comments on commit 3654614

Please sign in to comment.