Search in sources :

Example 16 with NitfParserInputFlowImpl

use of org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl in project alliance by codice.

the class RoutingSlipTest method testChannelImageNoTres.

@Test
public void testChannelImageNoTres() throws FileNotFoundException, NitfFormatException {
    NitfSegmentsFlow parserInputFlow = new NitfParserInputFlowImpl().file(new File(IMAGE_NO_TRE_NTF_FILENAME)).headerOnly();
    String channel = routingSlip.channel(parserInputFlow);
    assertThat(channel, is(RoutingSlip.IMAGE_ROUTE));
}
Also used : NitfSegmentsFlow(org.codice.imaging.nitf.fluent.NitfSegmentsFlow) NitfParserInputFlowImpl(org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl) File(java.io.File) Test(org.junit.Test)

Example 17 with NitfParserInputFlowImpl

use of org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl in project alliance by codice.

the class RoutingSlipTest method testChannelNoImageTre.

@Test
public void testChannelNoImageTre() throws FileNotFoundException, NitfFormatException {
    NitfSegmentsFlow parserInputFlow = new NitfParserInputFlowImpl().file(new File(NO_IMAGE_TRE_NTF_FILENAME)).headerOnly();
    String channel = routingSlip.channel(parserInputFlow);
    assertThat(channel, is(RoutingSlip.GMTI_ROUTE));
}
Also used : NitfSegmentsFlow(org.codice.imaging.nitf.fluent.NitfSegmentsFlow) NitfParserInputFlowImpl(org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl) File(java.io.File) Test(org.junit.Test)

Example 18 with NitfParserInputFlowImpl

use of org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl in project alliance by codice.

the class NitfHeaderTransformerTest method testValidationWarningsOnNitfAttributeTransformException.

@Test
public void testValidationWarningsOnNitfAttributeTransformException() throws Exception {
    String originalNitfValue = "US";
    NitfTestCommons.setupNitfUtilities(originalNitfValue, Arrays.asList("USA", "CAN"));
    File nitfFile = temporaryFolder.newFile("nitf-attribute-header-test.ntf");
    FileSecurityMetadata fileSecurityMetadata = TreUtilityTest.createSecurityMetadata();
    when(fileSecurityMetadata.getSecurityClassificationSystem()).thenReturn(originalNitfValue);
    Supplier<NitfHeader> nitfHeader = () -> TreUtilityTest.createFileHeader(fileSecurityMetadata);
    new NitfCreationFlowImpl().fileHeader(nitfHeader).write(nitfFile.getAbsolutePath());
    Metacard metacard;
    try (InputStream inputStream = new FileInputStream(nitfFile)) {
        metacard = metacardFactory.createMetacard("nitfHeaderTest");
        NitfSegmentsFlow nitfSegmentsFlow = new NitfParserInputFlowImpl().inputStream(inputStream).headerOnly();
        nitfHeaderTransformer.transform(nitfSegmentsFlow, metacard);
    }
    assertThat(metacard, is(not(nullValue())));
    assertThat(metacard.getAttribute(Validation.VALIDATION_WARNINGS).getValues().size(), equalTo(1));
    assertThat(metacard.getAttribute(Security.CLASSIFICATION_SYSTEM).getValue(), is(originalNitfValue));
}
Also used : NitfCreationFlowImpl(org.codice.imaging.nitf.fluent.impl.NitfCreationFlowImpl) Metacard(ddf.catalog.data.Metacard) NitfHeader(org.codice.imaging.nitf.core.header.NitfHeader) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) NitfSegmentsFlow(org.codice.imaging.nitf.fluent.NitfSegmentsFlow) NitfParserInputFlowImpl(org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl) File(java.io.File) FileSecurityMetadata(org.codice.imaging.nitf.core.security.FileSecurityMetadata) FileInputStream(java.io.FileInputStream) TreUtilityTest(org.codice.alliance.transformer.nitf.TreUtilityTest) Test(org.junit.Test)

Example 19 with NitfParserInputFlowImpl

use of org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl in project alliance by codice.

the class ImageInputTransformerTest method testNitfWithDifferentImageDates.

@Test
public void testNitfWithDifferentImageDates() throws Exception {
    File nitfFile = File.createTempFile("nitf-", ".ntf");
    try {
        final DateTime fileDateTime = NitfTestCommons.createNitfDateTime(2016, 1, 1, 0, 0, 0);
        DateTime[] imageDateTimes = { NitfTestCommons.createNitfDateTime(2001, 1, 1, 0, 0, 0), NitfTestCommons.createNitfDateTime(2002, 1, 1, 0, 0, 0), NitfTestCommons.createNitfDateTime(2003, 1, 1, 0, 0, 0) };
        createNitfWithDifferentImageDateTimes(nitfFile, fileDateTime, imageDateTimes);
        try (InputStream inputStream = new FileInputStream(nitfFile)) {
            Metacard metacard = metacardFactory.createMetacard("differentImageDateTimesTest");
            NitfSegmentsFlow nitfSegmentsFlow = new NitfParserInputFlowImpl().inputStream(inputStream).headerOnly();
            nitfSegmentsFlow = headerTransformer.transform(nitfSegmentsFlow, metacard);
            metacard = transformer.transform(nitfSegmentsFlow, metacard);
            assertNotNull(metacard);
            validateDates(metacard, fileDateTime, imageDateTimes);
        }
    } 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) NitfParserInputFlowImpl(org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl) File(java.io.File) DateTime(org.codice.imaging.nitf.core.common.DateTime) FileInputStream(java.io.FileInputStream) TreUtilityTest(org.codice.alliance.transformer.nitf.TreUtilityTest) Test(org.junit.Test)

Example 20 with NitfParserInputFlowImpl

use of org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl in project alliance by codice.

the class ImageInputTransformerTest method testPiaimc.

@Test
public void testPiaimc() throws IOException, NitfFormatException {
    File nitfFile = File.createTempFile("nitf-", ".ntf");
    try {
        createNitfWithPiaimc(nitfFile);
        try (InputStream inputStream = new FileInputStream(nitfFile)) {
            Metacard metacard = metacardFactory.createMetacard("csexraTest");
            NitfSegmentsFlow nitfSegmentsFlow = new NitfParserInputFlowImpl().inputStream(inputStream).headerOnly();
            transformer.transform(nitfSegmentsFlow, metacard);
            assertThat(metacard.getAttribute(Isr.CLOUD_COVER).getValue(), is(70.0));
        }
    } 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) 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

NitfParserInputFlowImpl (org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl)23 NitfSegmentsFlow (org.codice.imaging.nitf.fluent.NitfSegmentsFlow)22 Test (org.junit.Test)20 File (java.io.File)13 Metacard (ddf.catalog.data.Metacard)12 InputStream (java.io.InputStream)12 FileInputStream (java.io.FileInputStream)10 TreUtilityTest (org.codice.alliance.transformer.nitf.TreUtilityTest)10 BufferedImage (java.awt.image.BufferedImage)6 BinaryContent (ddf.catalog.data.BinaryContent)5 NitfAttribute (org.codice.alliance.transformer.nitf.common.NitfAttribute)5 ImageSegment (org.codice.imaging.nitf.core.image.ImageSegment)4 DateTime (org.codice.imaging.nitf.core.common.DateTime)3 NitfFormatException (org.codice.imaging.nitf.core.common.NitfFormatException)3 NitfHeader (org.codice.imaging.nitf.core.header.NitfHeader)3 FileSecurityMetadata (org.codice.imaging.nitf.core.security.FileSecurityMetadata)3 J2KImageWriteParam (com.github.jaiimageio.jpeg2000.J2KImageWriteParam)1 J2KImageReaderSpi (com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi)1 J2KImageWriter (com.github.jaiimageio.jpeg2000.impl.J2KImageWriter)1 J2KImageWriterSpi (com.github.jaiimageio.jpeg2000.impl.J2KImageWriterSpi)1