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()));
}
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()));
}
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));
}
Aggregations