use of org.codice.imaging.nitf.fluent.NitfSegmentsFlow in project alliance by codice.
the class ImageInputTransformerTest method testNullMetacard.
@Test(expected = IllegalArgumentException.class)
public void testNullMetacard() throws Exception {
NitfSegmentsFlow nitfSegmentsFlow = mock(NitfSegmentsFlow.class);
transformer.transform(nitfSegmentsFlow, null);
}
use of org.codice.imaging.nitf.fluent.NitfSegmentsFlow 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();
}
}
use of org.codice.imaging.nitf.fluent.NitfSegmentsFlow in project alliance by codice.
the class ImageInputTransformerTest method testNitfParsing.
@Test
public void testNitfParsing() throws Exception {
NitfSegmentsFlow nitfSegmentsFlow = new NitfParserInputFlowImpl().inputStream(getInputStream(GEO_NITF)).allData();
Metacard metacard = metacardFactory.createMetacard("101");
nitfSegmentsFlow = headerTransformer.transform(nitfSegmentsFlow, metacard);
metacard = transformer.transform(nitfSegmentsFlow, metacard);
assertNotNull(metacard);
assertThat(metacard.getMetacardType().getName(), is("isr.image"));
assertThat(metacard.getTitle(), is("Checks an uncompressed 1024x1024 8 bit mono image with GEOcentric data. Airfield"));
String wkt = metacard.getLocation();
assertTrue(wkt.matches("^POLYGON \\(\\(85 32.98\\d*, 85.00\\d* 32.98\\d*, 85.00\\d* 32.98\\d*, 85 32.98\\d*, 85 32.98\\d*\\)\\)"));
Map<NitfAttribute, NitfValue> map = initAttributesToBeAsserted();
assertAttributesMap(metacard, map);
validateDates(metacard, NitfTestCommons.createNitfDateTime(1997, 12, 17, 10, 26, 30), NitfTestCommons.createNitfDateTime(1996, 12, 17, 10, 26, 30));
}
use of org.codice.imaging.nitf.fluent.NitfSegmentsFlow in project alliance by codice.
the class CatalogOutputAdapter method getNitfSegmentsFlow.
NitfSegmentsFlow getNitfSegmentsFlow(InputStream resourceInputStream) throws NitfFormatException, IOException {
notNull(resourceInputStream, "resourceInputStream must be non-null");
NitfSegmentsFlow nitfSegmentsFlow;
try (TemporaryFileBackedOutputStream tfbos = createTemporaryFileBackedOutputStream()) {
IOUtils.copyLarge(resourceInputStream, tfbos);
try (InputStream is = tfbos.asByteSource().openBufferedStream()) {
nitfSegmentsFlow = new NitfParserInputFlowImpl().inputStream(is).allData();
}
}
return nitfSegmentsFlow;
}
use of org.codice.imaging.nitf.fluent.NitfSegmentsFlow in project alliance by codice.
the class CatalogOutputAdapterTest method testGrayscale.
@Test
public void testGrayscale() throws MimeTypeParseException, NitfFormatException, IOException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
int originalWidth = 200;
int originalHeight = 100;
int chipWidth = 160;
int chipHeight = 80;
NitfSegmentsFlow nitfSegmentsFlow = createGenericNitfSegmentFlow(originalWidth, originalHeight);
BufferedImage chipImage = new BufferedImage(chipWidth, chipHeight, BufferedImage.TYPE_BYTE_GRAY);
BinaryContent binaryContent = catalogOutputAdapter.getNitfBinaryContent(chipImage, nitfSegmentsFlow, 0, 0);
NitfSegmentsFlow chipNitfSegmentFlow = new NitfParserInputFlowImpl().inputStream(binaryContent.getInputStream()).allData();
chipNitfSegmentFlow.forEachImageSegment(imageSegment1 -> {
assertThat(imageSegment1.getPixelValueType(), is(PixelValueType.INTEGER));
assertThat(imageSegment1.getImageRepresentation(), is(ImageRepresentation.MONOCHROME));
assertThat(imageSegment1.getActualBitsPerPixelPerBand(), is(8));
assertThat(imageSegment1.getNumberOfBitsPerPixelPerBand(), is(8));
assertThat(imageSegment1.getImageBand(1).getImageRepresentation(), is("M"));
});
}
Aggregations