Search in sources :

Example 1 with Tre

use of org.codice.imaging.nitf.core.tre.Tre in project alliance by codice.

the class NitfGmtiTransformerTest method testClassificationCategory.

@Test
public void testClassificationCategory() throws NitfFormatException {
    Tre tre = mock(Tre.class);
    when(tre.getFieldValue(IndexedMtirpbAttribute.INDEXED_TARGET_CLASSIFICATION_CATEGORY_ATTRIBUTE.getShortName())).thenReturn(null);
    String value = IndexedMtirpbAttribute.INDEXED_TARGET_CLASSIFICATION_CATEGORY_ATTRIBUTE.getAccessorFunction().apply(tre).toString();
    assertThat(value, is("Unknown"));
}
Also used : Tre(org.codice.imaging.nitf.core.tre.Tre) TreUtilityTest(org.codice.alliance.transformer.nitf.TreUtilityTest) Test(org.junit.Test)

Example 2 with Tre

use of org.codice.imaging.nitf.core.tre.Tre in project alliance by codice.

the class ImageInputTransformerTest method createNitfWithAimidb.

private static Map<NitfAttribute, NitfValue> createNitfWithAimidb(File file) {
    String acquisitionDate = "20161013121212";
    String missionNumber = "UNKN";
    String country = "US";
    String location = "4559N23345W";
    Tre aimidb = TreFactory.getDefault("AIMIDB", TreSource.ImageExtendedSubheaderData);
    aimidb.add(new TreEntryImpl("ACQUISITION_DATE", acquisitionDate, "string"));
    aimidb.add(new TreEntryImpl("MISSION_NO", missionNumber, "string"));
    aimidb.add(new TreEntryImpl("MISSION_IDENTIFICATION", "NOT AVAIL.", "string"));
    aimidb.add(new TreEntryImpl("FLIGHT_NO", "01", "string"));
    aimidb.add(new TreEntryImpl("OP_NUM", "001", "UINT"));
    aimidb.add(new TreEntryImpl("CURRENT_SEGMENT", "AA", "string"));
    aimidb.add(new TreEntryImpl("REPRO_NUM", "01", "UINT"));
    aimidb.add(new TreEntryImpl("REPLAY", "000", "string"));
    aimidb.add(new TreEntryImpl("RESERVED_1", " ", "string"));
    aimidb.add(new TreEntryImpl("START_TILE_COLUMN", "001", "UINT"));
    aimidb.add(new TreEntryImpl("START_TILE_ROW", "00001", "UINT"));
    aimidb.add(new TreEntryImpl("END_SEGMENT", "AA", "string"));
    aimidb.add(new TreEntryImpl("END_TILE_COLUMN", "001", "UINT"));
    aimidb.add(new TreEntryImpl("END_TILE_ROW", "00001", "UINT"));
    aimidb.add(new TreEntryImpl("COUNTRY", country, "string"));
    aimidb.add(new TreEntryImpl("RESERVED_2", "    ", "string"));
    aimidb.add(new TreEntryImpl("LOCATION", location, "string"));
    aimidb.add(new TreEntryImpl("RESERVED_3", "             ", "string"));
    ImageSegment imageSegment = TreUtilityTest.createImageSegment();
    imageSegment.getTREsRawStructure().add(aimidb);
    new NitfCreationFlowImpl().fileHeader(() -> TreUtilityTest.createFileHeader()).imageSegment(() -> imageSegment).write(file.getAbsolutePath());
    // key value pair of nitf attributes and expected getAttributes
    Map<NitfAttribute, NitfValue> assertMap = new HashMap<>();
    assertMap.put(AimidbAttribute.ACQUISITION_DATE_ATTRIBUTE, new NitfValue(acquisitionDate));
    assertMap.put(AimidbAttribute.MISSION_NUMBER_ATTRIBUTE, new NitfValue(missionNumber));
    assertMap.put(AimidbAttribute.COUNTRY_CODE_ATTRIBUTE, new NitfValue(country));
    assertMap.put(AimidbAttribute.LOCATION_ATTRIBUTE, new NitfValue(location));
    return assertMap;
}
Also used : TreUtilityTest.createImageSegment(org.codice.alliance.transformer.nitf.TreUtilityTest.createImageSegment) ImageSegment(org.codice.imaging.nitf.core.image.ImageSegment) NitfCreationFlowImpl(org.codice.imaging.nitf.fluent.impl.NitfCreationFlowImpl) HashMap(java.util.HashMap) Tre(org.codice.imaging.nitf.core.tre.Tre) NitfAttribute(org.codice.alliance.transformer.nitf.common.NitfAttribute) TreEntryImpl(org.codice.imaging.nitf.core.tre.impl.TreEntryImpl)

Example 3 with Tre

use of org.codice.imaging.nitf.core.tre.Tre in project alliance by codice.

the class ImageInputTransformerTest method createNitfWithCsexra.

private static void createNitfWithCsexra(File file) {
    NitfHeader header = NitfHeaderFactory.getDefault(FileType.NITF_TWO_ONE);
    Tre csexra = TreFactory.getDefault("CSEXRA", TreSource.ImageExtendedSubheaderData);
    csexra.add(new TreEntryImpl("SNOW_DEPTH_CAT", "1", "string"));
    csexra.add(new TreEntryImpl("SENSOR", str(6), "string"));
    csexra.add(new TreEntryImpl("TIME_FIRST_LINE_IMAGE", "12345.000000", "string"));
    csexra.add(new TreEntryImpl("TIME_IMAGE_DURATION", "12345.000000", "string"));
    csexra.add(new TreEntryImpl("MAX_GSD", "123.5", "string"));
    csexra.add(new TreEntryImpl("ALONG_SCAN_GSD", "123.5", "string"));
    csexra.add(new TreEntryImpl("CROSS_SCAN_GSD", "123.5", "string"));
    csexra.add(new TreEntryImpl("GEO_MEAN_GSD", "123.5", "string"));
    csexra.add(new TreEntryImpl("A_S_VERT_GSD", "123.5", "string"));
    csexra.add(new TreEntryImpl("C_S_VERT_GSD", "123.5", "string"));
    csexra.add(new TreEntryImpl("GEO_MEAN_VERT_GSD", "123.5", "string"));
    csexra.add(new TreEntryImpl("GSD_BETA_ANGLE", "123.5", "string"));
    csexra.add(new TreEntryImpl("DYNAMIC_RANGE", "02047", "string"));
    csexra.add(new TreEntryImpl("NUM_LINES", "0000101", "string"));
    csexra.add(new TreEntryImpl("NUM_SAMPLES", "00101", "string"));
    csexra.add(new TreEntryImpl("ANGLE_TO_NORTH", "000.000", "string"));
    csexra.add(new TreEntryImpl("OBLIQUITY_ANGLE", "00.000", "string"));
    csexra.add(new TreEntryImpl("AZ_OF_OBLIQUITY", "000.000", "string"));
    csexra.add(new TreEntryImpl("GRD_COVER", "1", "string"));
    csexra.add(new TreEntryImpl("SNOW_DEPTH_CAT", "1", "string"));
    csexra.add(new TreEntryImpl("SUN_AZIMUTH", "000.000", "string"));
    csexra.add(new TreEntryImpl("SUN_ELEVATION", "-90.000", "string"));
    csexra.add(new TreEntryImpl("PREDICTED_NIIRS", "1.0", "string"));
    csexra.add(new TreEntryImpl("CIRCL_ERR", "000", "string"));
    csexra.add(new TreEntryImpl("LINEAR_ERR", "000", "string"));
    ImageSegment imageSegment = ImageSegmentFactory.getDefault(FileType.NITF_TWO_ONE);
    imageSegment.addImageBand(TreUtilityTest.createImageBand());
    imageSegment.getTREsRawStructure().add(csexra);
    new NitfCreationFlowImpl().fileHeader(() -> header).imageSegment(() -> imageSegment).write(file.getAbsolutePath());
}
Also used : TreUtilityTest.createImageSegment(org.codice.alliance.transformer.nitf.TreUtilityTest.createImageSegment) ImageSegment(org.codice.imaging.nitf.core.image.ImageSegment) NitfCreationFlowImpl(org.codice.imaging.nitf.fluent.impl.NitfCreationFlowImpl) NitfHeader(org.codice.imaging.nitf.core.header.NitfHeader) Tre(org.codice.imaging.nitf.core.tre.Tre) TreEntryImpl(org.codice.imaging.nitf.core.tre.impl.TreEntryImpl)

Example 4 with Tre

use of org.codice.imaging.nitf.core.tre.Tre in project alliance by codice.

the class ImageInputTransformerTest method createNitfWithPiaimc.

private static void createNitfWithPiaimc(File file) {
    NitfHeader header = NitfHeaderFactory.getDefault(FileType.NITF_TWO_ONE);
    Tre piaimc = TreFactory.getDefault("PIAIMC", TreSource.ImageExtendedSubheaderData);
    piaimc.add(new TreEntryImpl("CLOUDCVR", "070", "string"));
    piaimc.add(new TreEntryImpl("SRP", "Y", "string"));
    piaimc.add(new TreEntryImpl("SENSMODE", str(12), "string"));
    piaimc.add(new TreEntryImpl("SENSNAME", str(18), "string"));
    piaimc.add(new TreEntryImpl("SOURCE", str(255), "string"));
    piaimc.add(new TreEntryImpl("COMGEN", "09", "string"));
    piaimc.add(new TreEntryImpl("SUBQUAL", str(1), "string"));
    piaimc.add(new TreEntryImpl("PIAMSNNUM", str(7), "string"));
    piaimc.add(new TreEntryImpl("CAMSPECS", str(32), "string"));
    piaimc.add(new TreEntryImpl("PROJID", str(2), "string"));
    piaimc.add(new TreEntryImpl("GENERATION", "8", "string"));
    piaimc.add(new TreEntryImpl("ESD", "Y", "string"));
    piaimc.add(new TreEntryImpl("OTHERCOND", str(2), "string"));
    piaimc.add(new TreEntryImpl("MEANGSD", "00000.0", "string"));
    piaimc.add(new TreEntryImpl("IDATUM", str(3), "string"));
    piaimc.add(new TreEntryImpl("IELLIP", str(3), "string"));
    piaimc.add(new TreEntryImpl("PREPROC", str(2), "string"));
    piaimc.add(new TreEntryImpl("IPROJ", str(2), "string"));
    piaimc.add(new TreEntryImpl("SATTRACK_PATH", "0000", "string"));
    piaimc.add(new TreEntryImpl("SATTRACK_ROW", "0000", "string"));
    ImageSegment imageSegment = ImageSegmentFactory.getDefault(FileType.NITF_TWO_ONE);
    imageSegment.addImageBand(TreUtilityTest.createImageBand());
    imageSegment.getTREsRawStructure().add(piaimc);
    new NitfCreationFlowImpl().fileHeader(() -> header).imageSegment(() -> imageSegment).write(file.getAbsolutePath());
}
Also used : TreUtilityTest.createImageSegment(org.codice.alliance.transformer.nitf.TreUtilityTest.createImageSegment) ImageSegment(org.codice.imaging.nitf.core.image.ImageSegment) NitfCreationFlowImpl(org.codice.imaging.nitf.fluent.impl.NitfCreationFlowImpl) NitfHeader(org.codice.imaging.nitf.core.header.NitfHeader) Tre(org.codice.imaging.nitf.core.tre.Tre) TreEntryImpl(org.codice.imaging.nitf.core.tre.impl.TreEntryImpl)

Example 5 with Tre

use of org.codice.imaging.nitf.core.tre.Tre in project alliance by codice.

the class RoutingSlip method tresExist.

private Boolean tresExist(NitfHeader header) {
    TreCollection treCollection = header.getTREsRawStructure();
    List<Tre> mtirpbList = treCollection.getTREsWithName(MTIRPB);
    return !mtirpbList.isEmpty();
}
Also used : Tre(org.codice.imaging.nitf.core.tre.Tre) TreCollection(org.codice.imaging.nitf.core.tre.TreCollection)

Aggregations

Tre (org.codice.imaging.nitf.core.tre.Tre)14 TreEntryImpl (org.codice.imaging.nitf.core.tre.impl.TreEntryImpl)11 NitfCreationFlowImpl (org.codice.imaging.nitf.fluent.impl.NitfCreationFlowImpl)7 TreUtilityTest.createImageSegment (org.codice.alliance.transformer.nitf.TreUtilityTest.createImageSegment)6 ImageSegment (org.codice.imaging.nitf.core.image.ImageSegment)6 NitfHeader (org.codice.imaging.nitf.core.header.NitfHeader)4 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 NitfAttribute (org.codice.alliance.transformer.nitf.common.NitfAttribute)3 TreGroup (org.codice.imaging.nitf.core.tre.TreGroup)2 BufferedImage (java.awt.image.BufferedImage)1 TreUtilityTest (org.codice.alliance.transformer.nitf.TreUtilityTest)1 TreCollection (org.codice.imaging.nitf.core.tre.TreCollection)1