Search in sources :

Example 11 with KlvInt

use of org.codice.ddf.libs.klv.data.numerical.KlvInt in project ddf by codice.

the class KlvDecoderTest method testMissingBytes.

@Test
public void testMissingBytes() {
    final byte[] klvBytes = { -8, 4, (byte) 0x87, (byte) 0xF8, 0x4B };
    final KlvInt klvInt = new KlvInt(new byte[] { -8 }, "test");
    try {
        decodeKLV(KeyLength.ONE_BYTE, LengthEncoding.ONE_BYTE, klvInt, klvBytes);
        fail("Should have thrown a KlvDecodingException.");
    } catch (KlvDecodingException e) {
        assertThat(e.getCause(), instanceOf(IndexOutOfBoundsException.class));
    }
}
Also used : KlvInt(org.codice.ddf.libs.klv.data.numerical.KlvInt) Test(org.junit.Test)

Example 12 with KlvInt

use of org.codice.ddf.libs.klv.data.numerical.KlvInt in project ddf by codice.

the class KlvDecoderTest method isErrorIndicatedIntegerIndicatedFloatingPoint.

private boolean isErrorIndicatedIntegerIndicatedFloatingPoint(int value, Optional<Integer> errorValue) throws KlvDecodingException {
    KlvIntegerEncodedFloatingPoint klvIntegerEncodedFloatingPoint = new KlvIntegerEncodedFloatingPoint(new KlvInt(new byte[] { 0 }, "test", errorValue), Integer.MIN_VALUE + 1, Integer.MAX_VALUE, -90, 90);
    byte[] dataBytes = new byte[6];
    dataBytes[0] = 0;
    dataBytes[1] = 4;
    arraycopy(intToBytes(value), 0, dataBytes, 2, 4);
    return isErrorIndicatedDecode(klvIntegerEncodedFloatingPoint, dataBytes);
}
Also used : KlvIntegerEncodedFloatingPoint(org.codice.ddf.libs.klv.data.numerical.KlvIntegerEncodedFloatingPoint) KlvInt(org.codice.ddf.libs.klv.data.numerical.KlvInt)

Example 13 with KlvInt

use of org.codice.ddf.libs.klv.data.numerical.KlvInt in project ddf by codice.

the class KlvDecoderTest method setUpClass.

@BeforeClass
public static void setUpClass() {
    // The test KLV is a UAS Datalink Local Set (MISB ST 0601).
    EXPECTED_VALUES.put(TIMESTAMP, 1245257585099653L);
    EXPECTED_VALUES.put(UAS_LS_VERSION_NUMBER, (byte) 1);
    EXPECTED_VALUES.put(PLATFORM_HEADING_ANGLE, 15675);
    EXPECTED_VALUES.put(PLATFORM_PITCH_ANGLE, (short) 5504);
    EXPECTED_VALUES.put(PLATFORM_ROLL_ANGLE, (short) 338);
    EXPECTED_VALUES.put(IMAGE_SOURCE_SENSOR, "EON");
    EXPECTED_VALUES.put(IMAGE_COORDINATE_SYSTEM, "Geodetic WGS84");
    EXPECTED_VALUES.put(SENSOR_LATITUDE, 1304747195);
    EXPECTED_VALUES.put(SENSOR_LONGITUDE, -1314362114);
    EXPECTED_VALUES.put(SENSOR_TRUE_ALTITUDE, 8010);
    EXPECTED_VALUES.put(SENSOR_HORIZONTAL_FOV, 133);
    EXPECTED_VALUES.put(SENSOR_VERTICAL_FOV, 75);
    EXPECTED_VALUES.put(SENSOR_RELATIVE_AZIMUTH_ANGLE, 550031997L);
    EXPECTED_VALUES.put(SENSOR_RELATIVE_ELEVATION_ANGLE, -52624680);
    EXPECTED_VALUES.put(SENSOR_RELATIVE_ROLL_ANGLE, 4273523553L);
    EXPECTED_VALUES.put(SLANT_RANGE, 9387617L);
    EXPECTED_VALUES.put(TARGET_WIDTH, 457);
    EXPECTED_VALUES.put(FRAME_CENTER_LATITUDE, 1306364970);
    EXPECTED_VALUES.put(FRAME_CENTER_LONGITUDE, -1312907532);
    EXPECTED_VALUES.put(FRAME_CENTER_ELEVATION, 2949);
    EXPECTED_VALUES.put(TARGET_LOCATION_LATITUDE, 1306364970);
    EXPECTED_VALUES.put(TARGET_LOCATION_LONGITUDE, -1312907532);
    EXPECTED_VALUES.put(TARGET_LOCATION_ELEVATION, 2949);
    EXPECTED_VALUES.put(PLATFORM_GROUND_SPEED, (short) 46);
    EXPECTED_VALUES.put(GROUND_RANGE, 9294889L);
    EXPECTED_VALUES.put(CHECKSUM, 7263);
    DATA_ELEMENTS.add(new KlvLong(new byte[] { 0x02 }, TIMESTAMP));
    DATA_ELEMENTS.add(new KlvByte(new byte[] { 0x41 }, UAS_LS_VERSION_NUMBER));
    DATA_ELEMENTS.add(new KlvUnsignedShort(new byte[] { 0x05 }, PLATFORM_HEADING_ANGLE));
    DATA_ELEMENTS.add(new KlvShort(new byte[] { 0x06 }, PLATFORM_PITCH_ANGLE));
    DATA_ELEMENTS.add(new KlvShort(new byte[] { 0x07 }, PLATFORM_ROLL_ANGLE));
    DATA_ELEMENTS.add(new KlvString(new byte[] { 0x0b }, IMAGE_SOURCE_SENSOR));
    DATA_ELEMENTS.add(new KlvString(new byte[] { 0x0c }, IMAGE_COORDINATE_SYSTEM));
    DATA_ELEMENTS.add(new KlvInt(new byte[] { 0x0d }, SENSOR_LATITUDE));
    DATA_ELEMENTS.add(new KlvInt(new byte[] { 0x0e }, SENSOR_LONGITUDE));
    DATA_ELEMENTS.add(new KlvUnsignedShort(new byte[] { 0x0f }, SENSOR_TRUE_ALTITUDE));
    DATA_ELEMENTS.add(new KlvUnsignedShort(new byte[] { 0x10 }, SENSOR_HORIZONTAL_FOV));
    DATA_ELEMENTS.add(new KlvUnsignedShort(new byte[] { 0x11 }, SENSOR_VERTICAL_FOV));
    DATA_ELEMENTS.add(new KlvLong(new byte[] { 0x12 }, SENSOR_RELATIVE_AZIMUTH_ANGLE));
    DATA_ELEMENTS.add(new KlvInt(new byte[] { 0x13 }, SENSOR_RELATIVE_ELEVATION_ANGLE));
    DATA_ELEMENTS.add(new KlvLong(new byte[] { 0x14 }, SENSOR_RELATIVE_ROLL_ANGLE));
    DATA_ELEMENTS.add(new KlvLong(new byte[] { 0x15 }, SLANT_RANGE));
    // Target width isn't actually a 32-bit int in the UAS Datalink Local Set; it's an unsigned
    // 16-bit int. However, this KLV encodes the target width using 4 bytes (for some reason).
    DATA_ELEMENTS.add(new KlvInt(new byte[] { 0x16 }, TARGET_WIDTH));
    DATA_ELEMENTS.add(new KlvInt(new byte[] { 0x17 }, FRAME_CENTER_LATITUDE));
    DATA_ELEMENTS.add(new KlvInt(new byte[] { 0x18 }, FRAME_CENTER_LONGITUDE));
    DATA_ELEMENTS.add(new KlvUnsignedShort(new byte[] { 0x19 }, FRAME_CENTER_ELEVATION));
    DATA_ELEMENTS.add(new KlvInt(new byte[] { 0x28 }, TARGET_LOCATION_LATITUDE));
    DATA_ELEMENTS.add(new KlvInt(new byte[] { 0x29 }, TARGET_LOCATION_LONGITUDE));
    DATA_ELEMENTS.add(new KlvUnsignedShort(new byte[] { 0x2a }, TARGET_LOCATION_ELEVATION));
    DATA_ELEMENTS.add(new KlvUnsignedByte(new byte[] { 0x38 }, PLATFORM_GROUND_SPEED));
    DATA_ELEMENTS.add(new KlvLong(new byte[] { 0x39 }, GROUND_RANGE));
    DATA_ELEMENTS.add(new KlvUnsignedShort(new byte[] { 0x01 }, CHECKSUM));
}
Also used : KlvLong(org.codice.ddf.libs.klv.data.numerical.KlvLong) KlvByte(org.codice.ddf.libs.klv.data.numerical.KlvByte) KlvShort(org.codice.ddf.libs.klv.data.numerical.KlvShort) KlvUnsignedShort(org.codice.ddf.libs.klv.data.numerical.KlvUnsignedShort) KlvString(org.codice.ddf.libs.klv.data.text.KlvString) KlvUnsignedByte(org.codice.ddf.libs.klv.data.numerical.KlvUnsignedByte) KlvInt(org.codice.ddf.libs.klv.data.numerical.KlvInt) BeforeClass(org.junit.BeforeClass)

Aggregations

KlvInt (org.codice.ddf.libs.klv.data.numerical.KlvInt)13 Test (org.junit.Test)9 KlvIntegerEncodedFloatingPoint (org.codice.ddf.libs.klv.data.numerical.KlvIntegerEncodedFloatingPoint)4 HashSet (java.util.HashSet)1 KlvContext (org.codice.ddf.libs.klv.KlvContext)1 KlvByte (org.codice.ddf.libs.klv.data.numerical.KlvByte)1 KlvDouble (org.codice.ddf.libs.klv.data.numerical.KlvDouble)1 KlvLong (org.codice.ddf.libs.klv.data.numerical.KlvLong)1 KlvShort (org.codice.ddf.libs.klv.data.numerical.KlvShort)1 KlvUnsignedByte (org.codice.ddf.libs.klv.data.numerical.KlvUnsignedByte)1 KlvUnsignedShort (org.codice.ddf.libs.klv.data.numerical.KlvUnsignedShort)1 KlvString (org.codice.ddf.libs.klv.data.text.KlvString)1 BeforeClass (org.junit.BeforeClass)1