use of org.codice.imaging.nitf.core.header.NitfHeader in project alliance by codice.
the class TreUtilityTest method createFileHeaderWithMtirpb.
public static NitfHeader createFileHeaderWithMtirpb() throws NitfFormatException {
NitfHeader nitfHeader = createFileHeader();
TreCollection treCollection = nitfHeader.getTREsRawStructure();
treCollection.add(createMtirpbTre());
return nitfHeader;
}
use of org.codice.imaging.nitf.core.header.NitfHeader 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));
}
use of org.codice.imaging.nitf.core.header.NitfHeader in project alliance by codice.
the class ImageInputTransformerTest method createNitfWithCsdida.
private static void createNitfWithCsdida(File file) {
NitfHeader header = NitfHeaderFactory.getDefault(FileType.NITF_TWO_ONE);
Tre csdida = TreFactory.getDefault("CSDIDA", TreSource.ExtendedHeaderData);
csdida.add(new TreEntryImpl("DAY", "01", "UINT"));
csdida.add(new TreEntryImpl("MONTH", str(3), "UINT"));
csdida.add(new TreEntryImpl("YEAR", "1234", "UINT"));
csdida.add(new TreEntryImpl("PLATFORM_CODE", "XY", "string"));
csdida.add(new TreEntryImpl("VEHICLE_ID", "01", "string"));
csdida.add(new TreEntryImpl("PASS", "01", "string"));
csdida.add(new TreEntryImpl("OPERATION", "001", "UINT"));
csdida.add(new TreEntryImpl("SENSOR_ID", str(2), "string"));
csdida.add(new TreEntryImpl("PRODUCT_ID", str(2), "string"));
csdida.add(new TreEntryImpl("RESERVED_0", str(4), "string"));
csdida.add(new TreEntryImpl("TIME", "20000202010101", "UINT"));
csdida.add(new TreEntryImpl("PROCESS_TIME", "20000202010101", "UINT"));
csdida.add(new TreEntryImpl("RESERVED_1", str(2), "string"));
csdida.add(new TreEntryImpl("RESERVED_2", str(2), "string"));
csdida.add(new TreEntryImpl("RESERVED_3", str(1), "string"));
csdida.add(new TreEntryImpl("RESERVED_4", str(1), "string"));
csdida.add(new TreEntryImpl("SOFTWARE_VERSION_NUMBER", str(10), "string"));
header.getTREsRawStructure().add(csdida);
new NitfCreationFlowImpl().fileHeader(() -> header).write(file.getAbsolutePath());
}
use of org.codice.imaging.nitf.core.header.NitfHeader in project alliance by codice.
the class ImageInputTransformerTest method createNitfWithPiatgb.
private static void createNitfWithPiatgb(File file) {
NitfHeader header = NitfHeaderFactory.getDefault(FileType.NITF_TWO_ONE);
Tre piatgb = TreFactory.getDefault("PIATGB", TreSource.ImageExtendedSubheaderData);
piatgb.add(new TreEntryImpl("TGTUTM", "55HFA9359093610", "string"));
piatgb.add(new TreEntryImpl("PIATGAID", "ABCDEFGHIJUVWXY", "string"));
piatgb.add(new TreEntryImpl("PIACTRY", "AS", "string"));
piatgb.add(new TreEntryImpl("PIACAT", "702XX", "string"));
piatgb.add(new TreEntryImpl("TGTGEO", "351655S1490742E", "string"));
piatgb.add(new TreEntryImpl("DATUM", "WGE", "string"));
piatgb.add(new TreEntryImpl("TGTNAME", "Canberra Hill ", "string"));
piatgb.add(new TreEntryImpl("PERCOVER", "57", "UINT"));
piatgb.add(new TreEntryImpl("TGTLAT", "-35.30812 ", "float"));
piatgb.add(new TreEntryImpl("TGTLON", "+149.12447 ", "float"));
ImageSegment imageSegment = ImageSegmentFactory.getDefault(FileType.NITF_TWO_ONE);
imageSegment.addImageBand(TreUtilityTest.createImageBand());
imageSegment.getTREsRawStructure().add(piatgb);
new NitfCreationFlowImpl().fileHeader(() -> header).imageSegment(() -> imageSegment).write(file.getAbsolutePath());
}
Aggregations