Search in sources :

Example 1 with TreGroup

use of org.codice.imaging.nitf.core.tre.TreGroup in project alliance by codice.

the class TreUtilityTest method createTreGroup.

public static TreGroup createTreGroup(StringBuilder stringBuilder) throws NitfFormatException {
    final String[] treGroupFields = { "TGT_LOC", "TGT_LOC_ACCY", "TGT_VEL_R", "TGT_SPEED", "TGT_HEADING", "TGT_AMPLITUDE", "TGT_CAT" };
    final String[] treGroupValues = { "+52.1234567-004.1234567", "000.00", "+013", "000", "000", "06", "U" };
    TreGroup treGroup = mock(TreGroup.class);
    for (int i = 0; i < treGroupFields.length; i++) {
        when(treGroup.getFieldValue(treGroupFields[i])).thenReturn(treGroupValues[i]);
        stringBuilder.append(treGroupValues[i]);
    }
    return treGroup;
}
Also used : TreGroup(org.codice.imaging.nitf.core.tre.TreGroup)

Example 2 with TreGroup

use of org.codice.imaging.nitf.core.tre.TreGroup in project alliance by codice.

the class TreUtilityTest method createMtirpbTre.

public static Tre createMtirpbTre() throws NitfFormatException {
    final String[] fieldNames = { "MTI_DP", "MTI_PACKET_ID", "PATCH_NO", "WAMTI_FRAME_NO", "WAMTI_BAR_NO", "DATIME", "ACFT_LOC", "ACFT_ALT", "ACFT_ALT_UNIT", "ACFT_HEADING", "MTI_LR", "SQUINT_ANGLE", "COSGRZ", "NO_VALID_TARGETS" };
    final String[] values = { "00", "001", "0001", "00001", "1", "20141108235219", "+52.123456-004.123456", "150000", "m", "000", " ", "      ", "0.03111", "001" };
    StringBuilder accumulator = new StringBuilder();
    Tre tre = mock(Tre.class);
    when(tre.getName()).thenReturn("MTIRPB");
    for (int i = 0; i < fieldNames.length; i++) {
        accumulator.append(values[i]);
        when(tre.getEntry(fieldNames[i])).thenReturn(new TreEntryImpl(fieldNames[i], values[i], "string"));
    }
    TreGroup targetsGroup = createTreGroup(accumulator);
    TreEntryImpl targetsEntry = new TreEntryImpl("TARGETS");
    targetsEntry.addGroup(targetsGroup);
    when(tre.getEntry("TARGETS")).thenReturn(targetsEntry);
    when(tre.getSource()).thenReturn(TreSource.UserDefinedHeaderData);
    when(tre.getRawData()).thenReturn(accumulator.toString().getBytes());
    return tre;
}
Also used : Tre(org.codice.imaging.nitf.core.tre.Tre) TreGroup(org.codice.imaging.nitf.core.tre.TreGroup) TreEntryImpl(org.codice.imaging.nitf.core.tre.impl.TreEntryImpl)

Example 3 with TreGroup

use of org.codice.imaging.nitf.core.tre.TreGroup in project alliance by codice.

the class ImageInputTransformerTest method createNitfWithPiaprd.

private static Map<NitfAttribute, NitfValue> createNitfWithPiaprd(File file) throws NitfFormatException {
    String accessId = "THIS IS AN IPA FILE.                                       -END-";
    String keyword = "FIRST                                                             " + "                                                        " + "                                                        " + "                                                        " + "                -END-";
    Tre piaprd = TreFactory.getDefault("PIAPRD", TreSource.ImageExtendedSubheaderData);
    piaprd.add(new TreEntryImpl("ACCESSID", accessId, "string"));
    piaprd.add(new TreEntryImpl("FMCONTROL", "PXX                        -END-", "string"));
    piaprd.add(new TreEntryImpl("SUBDET", "P", "string"));
    piaprd.add(new TreEntryImpl("PRODCODE", "YY", "string"));
    piaprd.add(new TreEntryImpl("PRODUCERSE", "UNKNOW", "string"));
    piaprd.add(new TreEntryImpl("PRODIDNO", "X211           -END-", "string"));
    piaprd.add(new TreEntryImpl("PRODSNME", "JUNK FILE.", "string"));
    piaprd.add(new TreEntryImpl("PRODUCERCD", "27", "string"));
    piaprd.add(new TreEntryImpl("PRODCRTIME", "26081023ZOCT95", "string"));
    piaprd.add(new TreEntryImpl("MAPID", "132                                -END-", "string"));
    piaprd.add(new TreEntryImpl("SECTITLEREP", "01", "UINT"));
    TreEntryImpl secTitleEntry = new TreEntryImpl("SECTITLE", null, "string");
    TreGroup secTitleGroup = TreFactory.getDefault("SECTITLE", TreSource.ImageExtendedSubheaderData);
    secTitleGroup.getEntries().add(0, new TreEntryImpl("SECTITLE", "                                   -END-", "string"));
    secTitleGroup.getEntries().add(1, new TreEntryImpl("PPNUM", "32/47", "string"));
    secTitleGroup.getEntries().add(2, new TreEntryImpl("TPP", "001", "UINT"));
    secTitleEntry.initGroups();
    secTitleEntry.addGroup(secTitleGroup);
    piaprd.add(secTitleEntry);
    piaprd.add(new TreEntryImpl("REQORGREP", "01", "UINT"));
    TreEntryImpl reqorgEntry = new TreEntryImpl("REQORG", null, "string");
    TreGroup reqorgGroup = TreFactory.getDefault("REQORG", TreSource.ImageExtendedSubheaderData);
    reqorgGroup.getEntries().add(0, new TreEntryImpl("REQORG", "FIRST                                                      -END-", "string"));
    reqorgEntry.initGroups();
    reqorgEntry.addGroup(reqorgGroup);
    piaprd.add(reqorgEntry);
    piaprd.add(new TreEntryImpl("KEYWORDREP", "01", "UINT"));
    TreEntryImpl keywordEntry = new TreEntryImpl("KEYWORD", null, "string");
    TreGroup keywordGroup = TreFactory.getDefault("KEYWORD", TreSource.ImageExtendedSubheaderData);
    keywordGroup.getEntries().add(0, new TreEntryImpl("KEYWORD", keyword, "string"));
    keywordEntry.initGroups();
    keywordEntry.addGroup(keywordGroup);
    piaprd.add(keywordEntry);
    piaprd.add(new TreEntryImpl("ASSRPTREP", "01", "UNIT"));
    TreEntryImpl assrptEntry = new TreEntryImpl("ASSRPT", null, "string");
    TreGroup asserptGroup = TreFactory.getDefault("ASSRPT", TreSource.ImageExtendedSubheaderData);
    asserptGroup.getEntries().add(0, new TreEntryImpl("ASSRPT", "FIRST          -END-", "string"));
    assrptEntry.initGroups();
    assrptEntry.addGroup(asserptGroup);
    piaprd.add(assrptEntry);
    piaprd.add(new TreEntryImpl("ATEXTREP", "01", "UINT"));
    TreEntryImpl atextEntry = new TreEntryImpl("ATEXT", null, "string");
    TreGroup atextGroup = TreFactory.getDefault("ATEXT", TreSource.ImageExtendedSubheaderData);
    atextGroup.getEntries().add(0, new TreEntryImpl("ATEXT", "FIRST                                                             " + "                                                        " + "                                                        " + "                                                        " + "                -END-", "string"));
    atextEntry.initGroups();
    atextEntry.addGroup(atextGroup);
    piaprd.add(atextEntry);
    ImageSegment imageSegment = TreUtilityTest.createImageSegment();
    imageSegment.getTREsRawStructure().add(piaprd);
    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(PiaprdAttribute.ACCESS_ID_ATTRIBUTE, new NitfValue(accessId));
    assertMap.put(IndexedPiaprdAttribute.KEYWORD_ATTRIBUTE, new NitfValue(keyword));
    return assertMap;
}
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) HashMap(java.util.HashMap) Tre(org.codice.imaging.nitf.core.tre.Tre) TreGroup(org.codice.imaging.nitf.core.tre.TreGroup) NitfAttribute(org.codice.alliance.transformer.nitf.common.NitfAttribute) TreEntryImpl(org.codice.imaging.nitf.core.tre.impl.TreEntryImpl)

Aggregations

TreGroup (org.codice.imaging.nitf.core.tre.TreGroup)3 Tre (org.codice.imaging.nitf.core.tre.Tre)2 TreEntryImpl (org.codice.imaging.nitf.core.tre.impl.TreEntryImpl)2 HashMap (java.util.HashMap)1 TreUtilityTest.createImageSegment (org.codice.alliance.transformer.nitf.TreUtilityTest.createImageSegment)1 NitfAttribute (org.codice.alliance.transformer.nitf.common.NitfAttribute)1 ImageSegment (org.codice.imaging.nitf.core.image.ImageSegment)1 NitfCreationFlowImpl (org.codice.imaging.nitf.fluent.impl.NitfCreationFlowImpl)1