use of org.codice.imaging.nitf.core.tre.impl.TreEntryImpl in project alliance by codice.
the class ImageInputTransformerTest method createNitfWithAimidb.
private static Map<NitfAttribute, NitfValue> createNitfWithAimidb(File file) {
String acquisitionDate = "20161013121212";
String missionNumber = "UNKN";
String country = "US";
String location = "4559N23345W";
Tre aimidb = TreFactory.getDefault("AIMIDB", TreSource.ImageExtendedSubheaderData);
aimidb.add(new TreEntryImpl("ACQUISITION_DATE", acquisitionDate, "string"));
aimidb.add(new TreEntryImpl("MISSION_NO", missionNumber, "string"));
aimidb.add(new TreEntryImpl("MISSION_IDENTIFICATION", "NOT AVAIL.", "string"));
aimidb.add(new TreEntryImpl("FLIGHT_NO", "01", "string"));
aimidb.add(new TreEntryImpl("OP_NUM", "001", "UINT"));
aimidb.add(new TreEntryImpl("CURRENT_SEGMENT", "AA", "string"));
aimidb.add(new TreEntryImpl("REPRO_NUM", "01", "UINT"));
aimidb.add(new TreEntryImpl("REPLAY", "000", "string"));
aimidb.add(new TreEntryImpl("RESERVED_1", " ", "string"));
aimidb.add(new TreEntryImpl("START_TILE_COLUMN", "001", "UINT"));
aimidb.add(new TreEntryImpl("START_TILE_ROW", "00001", "UINT"));
aimidb.add(new TreEntryImpl("END_SEGMENT", "AA", "string"));
aimidb.add(new TreEntryImpl("END_TILE_COLUMN", "001", "UINT"));
aimidb.add(new TreEntryImpl("END_TILE_ROW", "00001", "UINT"));
aimidb.add(new TreEntryImpl("COUNTRY", country, "string"));
aimidb.add(new TreEntryImpl("RESERVED_2", " ", "string"));
aimidb.add(new TreEntryImpl("LOCATION", location, "string"));
aimidb.add(new TreEntryImpl("RESERVED_3", " ", "string"));
ImageSegment imageSegment = TreUtilityTest.createImageSegment();
imageSegment.getTREsRawStructure().add(aimidb);
new NitfCreationFlowImpl().fileHeader(() -> TreUtilityTest.createFileHeader()).imageSegment(() -> imageSegment).write(file.getAbsolutePath());
// key value pair of nitf attributes and expected getAttributes
Map<NitfAttribute, NitfValue> assertMap = new HashMap<>();
assertMap.put(AimidbAttribute.ACQUISITION_DATE_ATTRIBUTE, new NitfValue(acquisitionDate));
assertMap.put(AimidbAttribute.MISSION_NUMBER_ATTRIBUTE, new NitfValue(missionNumber));
assertMap.put(AimidbAttribute.COUNTRY_CODE_ATTRIBUTE, new NitfValue(country));
assertMap.put(AimidbAttribute.LOCATION_ATTRIBUTE, new NitfValue(location));
return assertMap;
}
use of org.codice.imaging.nitf.core.tre.impl.TreEntryImpl in project alliance by codice.
the class ImageInputTransformerTest method createNitfWithCsexra.
private static void createNitfWithCsexra(File file) {
NitfHeader header = NitfHeaderFactory.getDefault(FileType.NITF_TWO_ONE);
Tre csexra = TreFactory.getDefault("CSEXRA", TreSource.ImageExtendedSubheaderData);
csexra.add(new TreEntryImpl("SNOW_DEPTH_CAT", "1", "string"));
csexra.add(new TreEntryImpl("SENSOR", str(6), "string"));
csexra.add(new TreEntryImpl("TIME_FIRST_LINE_IMAGE", "12345.000000", "string"));
csexra.add(new TreEntryImpl("TIME_IMAGE_DURATION", "12345.000000", "string"));
csexra.add(new TreEntryImpl("MAX_GSD", "123.5", "string"));
csexra.add(new TreEntryImpl("ALONG_SCAN_GSD", "123.5", "string"));
csexra.add(new TreEntryImpl("CROSS_SCAN_GSD", "123.5", "string"));
csexra.add(new TreEntryImpl("GEO_MEAN_GSD", "123.5", "string"));
csexra.add(new TreEntryImpl("A_S_VERT_GSD", "123.5", "string"));
csexra.add(new TreEntryImpl("C_S_VERT_GSD", "123.5", "string"));
csexra.add(new TreEntryImpl("GEO_MEAN_VERT_GSD", "123.5", "string"));
csexra.add(new TreEntryImpl("GSD_BETA_ANGLE", "123.5", "string"));
csexra.add(new TreEntryImpl("DYNAMIC_RANGE", "02047", "string"));
csexra.add(new TreEntryImpl("NUM_LINES", "0000101", "string"));
csexra.add(new TreEntryImpl("NUM_SAMPLES", "00101", "string"));
csexra.add(new TreEntryImpl("ANGLE_TO_NORTH", "000.000", "string"));
csexra.add(new TreEntryImpl("OBLIQUITY_ANGLE", "00.000", "string"));
csexra.add(new TreEntryImpl("AZ_OF_OBLIQUITY", "000.000", "string"));
csexra.add(new TreEntryImpl("GRD_COVER", "1", "string"));
csexra.add(new TreEntryImpl("SNOW_DEPTH_CAT", "1", "string"));
csexra.add(new TreEntryImpl("SUN_AZIMUTH", "000.000", "string"));
csexra.add(new TreEntryImpl("SUN_ELEVATION", "-90.000", "string"));
csexra.add(new TreEntryImpl("PREDICTED_NIIRS", "1.0", "string"));
csexra.add(new TreEntryImpl("CIRCL_ERR", "000", "string"));
csexra.add(new TreEntryImpl("LINEAR_ERR", "000", "string"));
ImageSegment imageSegment = ImageSegmentFactory.getDefault(FileType.NITF_TWO_ONE);
imageSegment.addImageBand(TreUtilityTest.createImageBand());
imageSegment.getTREsRawStructure().add(csexra);
new NitfCreationFlowImpl().fileHeader(() -> header).imageSegment(() -> imageSegment).write(file.getAbsolutePath());
}
use of org.codice.imaging.nitf.core.tre.impl.TreEntryImpl in project alliance by codice.
the class ImageInputTransformerTest method createNitfWithPiaimc.
private static void createNitfWithPiaimc(File file) {
NitfHeader header = NitfHeaderFactory.getDefault(FileType.NITF_TWO_ONE);
Tre piaimc = TreFactory.getDefault("PIAIMC", TreSource.ImageExtendedSubheaderData);
piaimc.add(new TreEntryImpl("CLOUDCVR", "070", "string"));
piaimc.add(new TreEntryImpl("SRP", "Y", "string"));
piaimc.add(new TreEntryImpl("SENSMODE", str(12), "string"));
piaimc.add(new TreEntryImpl("SENSNAME", str(18), "string"));
piaimc.add(new TreEntryImpl("SOURCE", str(255), "string"));
piaimc.add(new TreEntryImpl("COMGEN", "09", "string"));
piaimc.add(new TreEntryImpl("SUBQUAL", str(1), "string"));
piaimc.add(new TreEntryImpl("PIAMSNNUM", str(7), "string"));
piaimc.add(new TreEntryImpl("CAMSPECS", str(32), "string"));
piaimc.add(new TreEntryImpl("PROJID", str(2), "string"));
piaimc.add(new TreEntryImpl("GENERATION", "8", "string"));
piaimc.add(new TreEntryImpl("ESD", "Y", "string"));
piaimc.add(new TreEntryImpl("OTHERCOND", str(2), "string"));
piaimc.add(new TreEntryImpl("MEANGSD", "00000.0", "string"));
piaimc.add(new TreEntryImpl("IDATUM", str(3), "string"));
piaimc.add(new TreEntryImpl("IELLIP", str(3), "string"));
piaimc.add(new TreEntryImpl("PREPROC", str(2), "string"));
piaimc.add(new TreEntryImpl("IPROJ", str(2), "string"));
piaimc.add(new TreEntryImpl("SATTRACK_PATH", "0000", "string"));
piaimc.add(new TreEntryImpl("SATTRACK_ROW", "0000", "string"));
ImageSegment imageSegment = ImageSegmentFactory.getDefault(FileType.NITF_TWO_ONE);
imageSegment.addImageBand(TreUtilityTest.createImageBand());
imageSegment.getTREsRawStructure().add(piaimc);
new NitfCreationFlowImpl().fileHeader(() -> header).imageSegment(() -> imageSegment).write(file.getAbsolutePath());
}
use of org.codice.imaging.nitf.core.tre.impl.TreEntryImpl in project alliance by codice.
the class CatalogOutputAdapter method createIchipb.
@SuppressWarnings("UnnecessaryLocalVariable")
Tre createIchipb(BufferedImage chip, int sourceX, int sourceY, float selectWidth, float selectHeight) {
Tre ichipb = TreFactory.getDefault("ICHIPB", TreSource.ImageExtendedSubheaderData);
ichipb.add(new TreEntryImpl("XFRM_FLAG", "00", UINT));
ichipb.add(new TreEntryImpl("SCALE_FACTOR", "0001.00000", REAL));
ichipb.add(new TreEntryImpl("ANAMRPH_CORR", "00", UINT));
ichipb.add(new TreEntryImpl("SCANBLK_NUM", "01", UINT));
float halfPixel = 0.5f;
float chipX0 = halfPixel;
float chipY0 = halfPixel;
float chipX1 = (float) chip.getWidth() - halfPixel;
float chipY1 = (float) chip.getHeight() - halfPixel;
ichipb.add(new TreEntryImpl("OP_ROW_11", formatCoord(chipY0), REAL));
ichipb.add(new TreEntryImpl("OP_COL_11", formatCoord(chipX0), REAL));
ichipb.add(new TreEntryImpl("OP_ROW_12", formatCoord(chipY0), REAL));
ichipb.add(new TreEntryImpl("OP_COL_12", formatCoord(chipX1), REAL));
ichipb.add(new TreEntryImpl("OP_ROW_21", formatCoord(chipY1), REAL));
ichipb.add(new TreEntryImpl("OP_COL_21", formatCoord(chipX0), REAL));
ichipb.add(new TreEntryImpl("OP_ROW_22", formatCoord(chipY1), REAL));
ichipb.add(new TreEntryImpl("OP_COL_22", formatCoord(chipX1), REAL));
float origX0 = sourceX + halfPixel;
float origY0 = sourceY + halfPixel;
float origX1 = sourceX + selectWidth - halfPixel;
float origY1 = sourceY + selectHeight - halfPixel;
ichipb.add(new TreEntryImpl("FI_ROW_11", formatCoord(origY0), REAL));
ichipb.add(new TreEntryImpl("FI_COL_11", formatCoord(origX0), REAL));
ichipb.add(new TreEntryImpl("FI_ROW_12", formatCoord(origY0), REAL));
ichipb.add(new TreEntryImpl("FI_COL_12", formatCoord(origX1), REAL));
ichipb.add(new TreEntryImpl("FI_ROW_21", formatCoord(origY1), REAL));
ichipb.add(new TreEntryImpl("FI_COL_21", formatCoord(origX0), REAL));
ichipb.add(new TreEntryImpl("FI_ROW_22", formatCoord(origY1), REAL));
ichipb.add(new TreEntryImpl("FI_COL_22", formatCoord(origX1), REAL));
ichipb.add(new TreEntryImpl("FI_ROW", "00000000", UINT));
ichipb.add(new TreEntryImpl("FI_COL", "00000000", UINT));
return ichipb;
}
use of org.codice.imaging.nitf.core.tre.impl.TreEntryImpl in project alliance by codice.
the class TreUtilityTest method testConvertToFloat.
@Test
public void testConvertToFloat() throws NitfFormatException, IOException {
Tre tre = TreFactory.getDefault("TestTre", TreSource.ImageExtendedSubheaderData);
tre.add(new TreEntryImpl("FLOAT_VALID_1", "+123.456e2", "float"));
tre.add(new TreEntryImpl("FLOAT_VALID_2", "-123", "float"));
tre.add(new TreEntryImpl("FLOAT_VALID_3", "0x1FFF.0p0", "float"));
tre.add(new TreEntryImpl("FLOAT_VALID_4", "0009.9000", "float"));
tre.add(new TreEntryImpl("FLOAT_VALID_5", "-0009.9000", "float"));
tre.add(new TreEntryImpl("FLOAT_INVALID_1", "0D2310", "float"));
tre.add(new TreEntryImpl("FLOAT_INVALID_2", "-0w.D3", "float"));
tre.add(new TreEntryImpl("FLOAT_INVALID_3", "-+0x1FFF.0p0", "float"));
tre.add(new TreEntryImpl("FLOAT_INVALID_4", "12367.0x0FF", "float"));
tre.add(new TreEntryImpl("FLOAT_INVALID_5", "1,0", "float"));
assertThat(TreUtility.convertToFloat(tre, "FLOAT_VALID_1"), is(12345.6f));
assertThat(TreUtility.convertToFloat(tre, "FLOAT_VALID_2"), is(-123.0f));
assertThat(TreUtility.convertToFloat(tre, "FLOAT_VALID_3"), is(8191.0f));
assertThat(TreUtility.convertToFloat(tre, "FLOAT_VALID_4"), is(9.9f));
assertThat(TreUtility.convertToFloat(tre, "FLOAT_VALID_5"), is(-9.9f));
assertThat(TreUtility.convertToFloat(tre, "FLOAT_INVALID_1"), nullValue());
assertThat(TreUtility.convertToFloat(tre, "FLOAT_INVALID_2"), nullValue());
assertThat(TreUtility.convertToFloat(tre, "FLOAT_INVALID_3"), nullValue());
assertThat(TreUtility.convertToFloat(tre, "FLOAT_INVALID_4"), nullValue());
assertThat(TreUtility.convertToFloat(tre, "FLOAT_INVALID_5"), nullValue());
}
Aggregations