Search in sources :

Example 1 with NitfAttribute

use of org.codice.alliance.transformer.nitf.common.NitfAttribute in project alliance by codice.

the class NitfGmtiTransformerTest method testTre.

@Test
public void testTre() throws IOException, CatalogTransformerException, NitfFormatException {
    NitfSegmentsFlow nitfSegmentsFlow = new NitfParserInputFlowImpl().inputStream(getInputStream(GMTI_TEST_NITF)).allData();
    Metacard metacard = metacardFactory.createMetacard("101");
    nitfSegmentsFlow = nitfHeaderTransformer.transform(nitfSegmentsFlow, metacard);
    metacard = nitfGmtiTransformer.transform(nitfSegmentsFlow, metacard);
    assertNotNull(metacard);
    validateDate(metacard.getCreatedDate(), "2016-06-22 23:39:22");
    validateDate(metacard.getEffectiveDate(), "2016-06-22 23:39:22");
    validateDate(metacard.getModifiedDate(), "2016-06-22 23:39:22");
    assertThat(metacard.getMetacardType().getName(), is("isr.gmti"));
    Map<NitfAttribute, String> mtirpbAttributesMap = initMtirpbAttributes();
    assertMtirpbAttributes(metacard, mtirpbAttributesMap);
}
Also used : Metacard(ddf.catalog.data.Metacard) NitfSegmentsFlow(org.codice.imaging.nitf.fluent.NitfSegmentsFlow) NitfAttribute(org.codice.alliance.transformer.nitf.common.NitfAttribute) NitfParserInputFlowImpl(org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl) TreUtilityTest(org.codice.alliance.transformer.nitf.TreUtilityTest) Test(org.junit.Test)

Example 2 with NitfAttribute

use of org.codice.alliance.transformer.nitf.common.NitfAttribute in project alliance by codice.

the class ImageInputTransformerTest method testPiaprd.

@Test
public void testPiaprd() throws IOException, NitfFormatException {
    File nitfFile = File.createTempFile("nitf-", ".ntf");
    try {
        Map<NitfAttribute, NitfValue> treMap = createNitfWithPiaprd(nitfFile);
        try (InputStream inputStream = new FileInputStream(nitfFile)) {
            Metacard metacard = metacardFactory.createMetacard("piaprdTest");
            NitfSegmentsFlow nitfSegmentsFlow = new NitfParserInputFlowImpl().inputStream(inputStream).headerOnly();
            headerTransformer.transform(nitfSegmentsFlow, metacard);
            transformer.transform(nitfSegmentsFlow, metacard);
            assertAttributesMap(metacard, treMap);
        }
    } finally {
        nitfFile.delete();
    }
}
Also used : Metacard(ddf.catalog.data.Metacard) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) NitfSegmentsFlow(org.codice.imaging.nitf.fluent.NitfSegmentsFlow) NitfAttribute(org.codice.alliance.transformer.nitf.common.NitfAttribute) NitfParserInputFlowImpl(org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl) File(java.io.File) FileInputStream(java.io.FileInputStream) TreUtilityTest(org.codice.alliance.transformer.nitf.TreUtilityTest) Test(org.junit.Test)

Example 3 with NitfAttribute

use of org.codice.alliance.transformer.nitf.common.NitfAttribute 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 4 with NitfAttribute

use of org.codice.alliance.transformer.nitf.common.NitfAttribute in project alliance by codice.

the class ImageInputTransformerTest method testAimidb.

@Test
public void testAimidb() throws IOException, NitfFormatException {
    File nitfFile = File.createTempFile("nitf-", ".ntf");
    try {
        Map<NitfAttribute, NitfValue> treMap = createNitfWithAimidb(nitfFile);
        try (InputStream inputStream = new FileInputStream(nitfFile)) {
            Metacard metacard = metacardFactory.createMetacard("aimidbTest");
            NitfSegmentsFlow nitfSegmentsFlow = new NitfParserInputFlowImpl().inputStream(inputStream).headerOnly();
            headerTransformer.transform(nitfSegmentsFlow, metacard);
            transformer.transform(nitfSegmentsFlow, metacard);
            assertAttributesMap(metacard, treMap);
        }
    } finally {
        nitfFile.delete();
    }
}
Also used : Metacard(ddf.catalog.data.Metacard) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) NitfSegmentsFlow(org.codice.imaging.nitf.fluent.NitfSegmentsFlow) NitfAttribute(org.codice.alliance.transformer.nitf.common.NitfAttribute) NitfParserInputFlowImpl(org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl) File(java.io.File) FileInputStream(java.io.FileInputStream) TreUtilityTest(org.codice.alliance.transformer.nitf.TreUtilityTest) Test(org.junit.Test)

Example 5 with NitfAttribute

use of org.codice.alliance.transformer.nitf.common.NitfAttribute in project alliance by codice.

the class ImageInputTransformerTest method testExpltb.

@Test
public void testExpltb() throws IOException, NitfFormatException {
    File nitfFile = File.createTempFile("nitf-", ".ntf");
    try {
        Map<NitfAttribute, NitfValue> treMap = createNitfWithExpltb(nitfFile);
        try (InputStream inputStream = new FileInputStream(nitfFile)) {
            Metacard metacard = metacardFactory.createMetacard("expltbTest");
            NitfSegmentsFlow nitfSegmentsFlow = new NitfParserInputFlowImpl().inputStream(inputStream).headerOnly();
            headerTransformer.transform(nitfSegmentsFlow, metacard);
            transformer.transform(nitfSegmentsFlow, metacard);
            assertAttributesMap(metacard, treMap);
        }
    } finally {
        nitfFile.delete();
    }
}
Also used : Metacard(ddf.catalog.data.Metacard) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) NitfSegmentsFlow(org.codice.imaging.nitf.fluent.NitfSegmentsFlow) NitfAttribute(org.codice.alliance.transformer.nitf.common.NitfAttribute) NitfParserInputFlowImpl(org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl) File(java.io.File) FileInputStream(java.io.FileInputStream) TreUtilityTest(org.codice.alliance.transformer.nitf.TreUtilityTest) Test(org.junit.Test)

Aggregations

NitfAttribute (org.codice.alliance.transformer.nitf.common.NitfAttribute)9 Metacard (ddf.catalog.data.Metacard)5 TreUtilityTest (org.codice.alliance.transformer.nitf.TreUtilityTest)5 NitfSegmentsFlow (org.codice.imaging.nitf.fluent.NitfSegmentsFlow)5 NitfParserInputFlowImpl (org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl)5 Test (org.junit.Test)5 File (java.io.File)3 FileInputStream (java.io.FileInputStream)3 InputStream (java.io.InputStream)3 HashMap (java.util.HashMap)3 TreUtilityTest.createImageSegment (org.codice.alliance.transformer.nitf.TreUtilityTest.createImageSegment)3 ImageSegment (org.codice.imaging.nitf.core.image.ImageSegment)3 Tre (org.codice.imaging.nitf.core.tre.Tre)3 TreEntryImpl (org.codice.imaging.nitf.core.tre.impl.TreEntryImpl)3 NitfCreationFlowImpl (org.codice.imaging.nitf.fluent.impl.NitfCreationFlowImpl)3 Attribute (ddf.catalog.data.Attribute)1 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)1 Set (java.util.Set)1 AimidbAttribute (org.codice.alliance.transformer.nitf.common.AimidbAttribute)1 ExpltbAttribute (org.codice.alliance.transformer.nitf.common.ExpltbAttribute)1