Search in sources :

Example 26 with NitfSegmentsFlow

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

the class NitfParserServiceTest method testParseNitfHeadersOnly.

@Test
public void testParseNitfHeadersOnly() throws NitfFormatException {
    InputStream is = getInputStream(GEO_NITF);
    NitfSegmentsFlow nitfSegmentsFlow = this.nitfParserAdapter.parseNitf(is, false);
    MatcherAssert.assertThat(nitfSegmentsFlow, Is.is(CoreMatchers.notNullValue()));
}
Also used : InputStream(java.io.InputStream) NitfSegmentsFlow(org.codice.imaging.nitf.fluent.NitfSegmentsFlow) Test(org.junit.Test)

Example 27 with NitfSegmentsFlow

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

the class NitfParserServiceTest method testParseNitfAllData.

@Test
public void testParseNitfAllData() throws NitfFormatException {
    InputStream is = getInputStream(GEO_NITF);
    NitfSegmentsFlow nitfSegmentsFlow = this.nitfParserAdapter.parseNitf(is, true);
    MatcherAssert.assertThat(nitfSegmentsFlow, Is.is(CoreMatchers.notNullValue()));
}
Also used : InputStream(java.io.InputStream) NitfSegmentsFlow(org.codice.imaging.nitf.fluent.NitfSegmentsFlow) Test(org.junit.Test)

Example 28 with NitfSegmentsFlow

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

the class ImagingTest method testImageNitfChipCreationNitf.

@Test
public void testImageNitfChipCreationNitf() throws Exception {
    String id = ingestNitfFile(TEST_IMAGE_NITF);
    String chippingUrl = SECURE_ROOT + HTTPS_PORT.getPort() + "/chipping/chipping.html?id=" + id + "&source=Alliance";
    given().get(chippingUrl).then().assertThat().statusCode(HttpStatus.SC_OK);
    final int width = 350;
    final int height = 240;
    String chippedImageUrl = SERVICE_ROOT + "/catalog/" + id + "?transform=nitf-chip&qualifier=overview&x=" + 300 + "&y=" + 200 + "&w=" + width + "&h=" + height;
    InputStream chippedImageStream = given().get(chippedImageUrl).asInputStream();
    List<ImageSegment> imageSegments = new LinkedList<>();
    try (TemporaryFileBackedOutputStream tfbos = new TemporaryFileBackedOutputStream()) {
        IOUtils.copyLarge(chippedImageStream, tfbos);
        NitfSegmentsFlow nitfSegmentsFlow = new NitfParserInputFlowImpl().inputStream(tfbos.asByteSource().openBufferedStream()).allData();
        nitfSegmentsFlow.forEachImageSegment(imageSegments::add);
    }
    assertThat(imageSegments, hasSize(1));
    assertThat(imageSegments.get(0).getNumberOfColumns(), is((long) width));
    assertThat(imageSegments.get(0).getNumberOfRows(), is((long) height));
}
Also used : ImageSegment(org.codice.imaging.nitf.core.image.ImageSegment) TemporaryFileBackedOutputStream(org.codice.ddf.platform.util.TemporaryFileBackedOutputStream) InputStream(java.io.InputStream) NitfSegmentsFlow(org.codice.imaging.nitf.fluent.NitfSegmentsFlow) NitfParserInputFlowImpl(org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl) LinkedList(java.util.LinkedList) AbstractAllianceIntegrationTest(org.codice.alliance.test.itests.common.AbstractAllianceIntegrationTest) Test(org.junit.Test)

Aggregations

NitfSegmentsFlow (org.codice.imaging.nitf.fluent.NitfSegmentsFlow)28 Test (org.junit.Test)25 NitfParserInputFlowImpl (org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl)22 File (java.io.File)13 InputStream (java.io.InputStream)13 Metacard (ddf.catalog.data.Metacard)12 TreUtilityTest (org.codice.alliance.transformer.nitf.TreUtilityTest)12 FileInputStream (java.io.FileInputStream)10 BinaryContent (ddf.catalog.data.BinaryContent)5 BufferedImage (java.awt.image.BufferedImage)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 NitfHeader (org.codice.imaging.nitf.core.header.NitfHeader)3 ImageCoordinates (org.codice.imaging.nitf.core.image.ImageCoordinates)3 FileSecurityMetadata (org.codice.imaging.nitf.core.security.FileSecurityMetadata)3 TemporaryFileBackedOutputStream (org.codice.ddf.platform.util.TemporaryFileBackedOutputStream)2 DataSource (org.codice.imaging.nitf.core.DataSource)2 NitfFormatException (org.codice.imaging.nitf.core.common.NitfFormatException)2 TargetIdImpl (org.codice.imaging.nitf.core.image.impl.TargetIdImpl)2