Search in sources :

Example 1 with NitfHeader

use of org.codice.imaging.nitf.core.header.NitfHeader 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());
}
Also used : TreUtilityTest.createImageSegment(org.codice.alliance.transformer.nitf.TreUtilityTest.createImageSegment) ImageSegment(org.codice.imaging.nitf.core.image.ImageSegment) NitfCreationFlowImpl(org.codice.imaging.nitf.fluent.impl.NitfCreationFlowImpl) NitfHeader(org.codice.imaging.nitf.core.header.NitfHeader) Tre(org.codice.imaging.nitf.core.tre.Tre) TreEntryImpl(org.codice.imaging.nitf.core.tre.impl.TreEntryImpl)

Example 2 with NitfHeader

use of org.codice.imaging.nitf.core.header.NitfHeader 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());
}
Also used : TreUtilityTest.createImageSegment(org.codice.alliance.transformer.nitf.TreUtilityTest.createImageSegment) ImageSegment(org.codice.imaging.nitf.core.image.ImageSegment) NitfCreationFlowImpl(org.codice.imaging.nitf.fluent.impl.NitfCreationFlowImpl) NitfHeader(org.codice.imaging.nitf.core.header.NitfHeader) Tre(org.codice.imaging.nitf.core.tre.Tre) TreEntryImpl(org.codice.imaging.nitf.core.tre.impl.TreEntryImpl)

Example 3 with NitfHeader

use of org.codice.imaging.nitf.core.header.NitfHeader in project alliance by codice.

the class TreUtilityTest method createFileHeader.

public static NitfHeader createFileHeader(DateTime fileDateTime) {
    TreCollection treCollection = new TreCollectionImpl();
    FileSecurityMetadata securityMetadata = createSecurityMetadata();
    NitfHeader nitfHeader = mock(NitfHeader.class);
    when(nitfHeader.getFileTitle()).thenReturn("TEST NITF");
    when(nitfHeader.getFileType()).thenReturn(FileType.NITF_TWO_ONE);
    when(nitfHeader.getComplexityLevel()).thenReturn(1);
    when(nitfHeader.getFileDateTime()).thenReturn(fileDateTime);
    when(nitfHeader.getOriginatingStationId()).thenReturn("LOCALHOST");
    when(nitfHeader.getStandardType()).thenReturn("BF01");
    when(nitfHeader.getFileBackgroundColour()).thenReturn(new RGBColourImpl((byte) 0, (byte) 0, (byte) 0));
    when(nitfHeader.getOriginatorsName()).thenReturn("");
    when(nitfHeader.getOriginatorsPhoneNumber()).thenReturn("");
    when(nitfHeader.getFileSecurityMetadata()).thenReturn(securityMetadata);
    when(nitfHeader.getTREsRawStructure()).thenReturn(treCollection);
    return nitfHeader;
}
Also used : RGBColourImpl(org.codice.imaging.nitf.core.impl.RGBColourImpl) NitfHeader(org.codice.imaging.nitf.core.header.NitfHeader) TreCollectionImpl(org.codice.imaging.nitf.core.tre.impl.TreCollectionImpl) FileSecurityMetadata(org.codice.imaging.nitf.core.security.FileSecurityMetadata) TreCollection(org.codice.imaging.nitf.core.tre.TreCollection)

Example 4 with NitfHeader

use of org.codice.imaging.nitf.core.header.NitfHeader in project alliance by codice.

the class CatalogOutputAdapter method createChipHeader.

private NitfHeader createChipHeader(NitfSegmentsFlow nitfSegmentsFlow) {
    NitfHeader chipHeader = NitfHeaderFactory.getDefault(FileType.NITF_TWO_ONE);
    nitfSegmentsFlow.fileHeader(originalHeader -> {
        chipHeader.setFileTitle(originalHeader.getFileTitle());
        chipHeader.setOriginatingStationId(originalHeader.getOriginatingStationId());
        chipHeader.setFileBackgroundColour(originalHeader.getFileBackgroundColour());
        chipHeader.setFileDateTime(DateTimeImpl.getNitfDateTimeForNow());
        chipHeader.setFileSecurityMetadata(originalHeader.getFileSecurityMetadata());
        chipHeader.setOriginatorsName(originalHeader.getOriginatorsName());
        chipHeader.setOriginatorsPhoneNumber(originalHeader.getOriginatorsPhoneNumber());
        chipHeader.setSecurityMetadata(originalHeader.getFileSecurityMetadata());
        chipHeader.setStandardType(originalHeader.getStandardType());
        chipHeader.setUserDefinedHeaderOverflow(0);
        chipHeader.setExtendedHeaderDataOverflow(0);
        chipHeader.setComplexityLevel(originalHeader.getComplexityLevel());
    });
    return chipHeader;
}
Also used : NitfHeader(org.codice.imaging.nitf.core.header.NitfHeader)

Example 5 with NitfHeader

use of org.codice.imaging.nitf.core.header.NitfHeader in project alliance by codice.

the class CatalogOutputAdapter method getNitfBinaryContent.

/**
 * Create a NITF of a chip that extracted from another NITF.
 *
 * @param chip the image data for the chipped area
 * @param nitfSegmentsFlow the segments from the original nitf
 * @param sourceX the x pixel coordinates of the original nitf where the chip was extracted
 * @param sourceY the y pixel coordinates of the original nitf where the chip was extracted
 * @return a nitf file containing the chip
 */
@SuppressWarnings("unused")
public BinaryContent getNitfBinaryContent(BufferedImage chip, NitfSegmentsFlow nitfSegmentsFlow, int sourceX, int sourceY) throws IOException, MimeTypeParseException, NitfFormatException {
    try {
        NitfHeader chipHeader = createChipHeader(nitfSegmentsFlow);
        nitfSegmentsFlow.fileHeader(nitfHeader -> copySDEs(nitfHeader, chipHeader));
        ImageSegment chipImageSegment = createChipImageSegment(chip, sourceX, sourceY, nitfSegmentsFlow);
        addIchipbTre(chip, sourceX, sourceY, chipImageSegment);
        List<ImageSegment> imageSegments = getImageSegments(nitfSegmentsFlow);
        if (!imageSegments.isEmpty()) {
            copySDEs(imageSegments.get(0), chipImageSegment);
        }
        return nitfToBinaryContent(chipHeader, chipImageSegment);
    } finally {
        nitfSegmentsFlow.end();
    }
}
Also used : ImageSegment(org.codice.imaging.nitf.core.image.ImageSegment) NitfHeader(org.codice.imaging.nitf.core.header.NitfHeader)

Aggregations

NitfHeader (org.codice.imaging.nitf.core.header.NitfHeader)14 ImageSegment (org.codice.imaging.nitf.core.image.ImageSegment)7 FileSecurityMetadata (org.codice.imaging.nitf.core.security.FileSecurityMetadata)5 NitfCreationFlowImpl (org.codice.imaging.nitf.fluent.impl.NitfCreationFlowImpl)5 Tre (org.codice.imaging.nitf.core.tre.Tre)4 TreEntryImpl (org.codice.imaging.nitf.core.tre.impl.TreEntryImpl)4 TreUtilityTest.createImageSegment (org.codice.alliance.transformer.nitf.TreUtilityTest.createImageSegment)3 DataSource (org.codice.imaging.nitf.core.DataSource)3 DateTime (org.codice.imaging.nitf.core.common.DateTime)3 ImageCoordinates (org.codice.imaging.nitf.core.image.ImageCoordinates)3 SecurityMetadata (org.codice.imaging.nitf.core.security.SecurityMetadata)3 NitfSegmentsFlow (org.codice.imaging.nitf.fluent.NitfSegmentsFlow)3 NitfParserInputFlowImpl (org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl)3 NitfSegmentsFlowImpl (org.codice.imaging.nitf.fluent.impl.NitfSegmentsFlowImpl)3 Test (org.junit.Test)3 BinaryContent (ddf.catalog.data.BinaryContent)2 BufferedImage (java.awt.image.BufferedImage)2 NitfFormatException (org.codice.imaging.nitf.core.common.NitfFormatException)2 TargetIdImpl (org.codice.imaging.nitf.core.image.impl.TargetIdImpl)2 RGBColourImpl (org.codice.imaging.nitf.core.impl.RGBColourImpl)2