Search in sources :

Example 6 with NitfAttribute

use of org.codice.alliance.transformer.nitf.common.NitfAttribute 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));
}
Also used : Metacard(ddf.catalog.data.Metacard) NitfSegmentsFlow(org.codice.imaging.nitf.fluent.NitfSegmentsFlow) NitfAttribute(org.codice.alliance.transformer.nitf.common.NitfAttribute) NitfParserInputFlowImpl(org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl) TreUtilityTest(org.codice.alliance.transformer.nitf.TreUtilityTest) Test(org.junit.Test)

Example 7 with NitfAttribute

use of org.codice.alliance.transformer.nitf.common.NitfAttribute 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)

Example 8 with NitfAttribute

use of org.codice.alliance.transformer.nitf.common.NitfAttribute in project alliance by codice.

the class ImageInputTransformerTest method createNitfWithExpltb.

private static Map<NitfAttribute, NitfValue> createNitfWithExpltb(File file) {
    String angleToNorth = "150.001";
    String angleToNorthAccuracy = "03.001";
    String mode = "LBM";
    String primeId = "aaaaaaaaaaaa";
    Tre expltb = TreFactory.getDefault("EXPLTB", TreSource.ImageExtendedSubheaderData);
    expltb.add(new TreEntryImpl("ANGLE_TO_NORTH", angleToNorth, "float"));
    expltb.add(new TreEntryImpl("ANGLE_TO_NORTH_ACCY", angleToNorthAccuracy, "float"));
    expltb.add(new TreEntryImpl("SQUINT_ANGLE", "-59.002", "float"));
    expltb.add(new TreEntryImpl("SQUINT_ANGLE_ACCY", "44.002", "float"));
    expltb.add(new TreEntryImpl("MODE", mode, "string"));
    expltb.add(new TreEntryImpl("GRAZE_ANG", "50.00", "float"));
    expltb.add(new TreEntryImpl("GRAZE_ANG_ACCY", "00.01", "float"));
    expltb.add(new TreEntryImpl("SLOPE_ANG", "24.00", "float"));
    expltb.add(new TreEntryImpl("POLAR", "HH", "UINT"));
    expltb.add(new TreEntryImpl("NSAMP", "03333", "UINT"));
    expltb.add(new TreEntryImpl("SEQ_NUM", "4", "string"));
    expltb.add(new TreEntryImpl("PRIME_ID", primeId, "string"));
    expltb.add(new TreEntryImpl("PRIME_BE", "bbbbbbbbbbbbbbb", "string"));
    expltb.add(new TreEntryImpl("N_SEC", "11", "UINT"));
    expltb.add(new TreEntryImpl("IPR", "22", "UINT"));
    ImageSegment imageSegment = TreUtilityTest.createImageSegment();
    imageSegment.getTREsRawStructure().add(expltb);
    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(ExpltbAttribute.ANGLE_TO_NORTH_ATTRIBUTE, new NitfValue(Float.parseFloat(angleToNorth)));
    assertMap.put(ExpltbAttribute.ANGLE_TO_NORTH_ACCURACY_ATTRIBUTE, new NitfValue(Float.parseFloat(angleToNorthAccuracy)));
    assertMap.put(ExpltbAttribute.MODE_ATTRIBUTE, new NitfValue(mode));
    assertMap.put(ExpltbAttribute.PRIME_ID_ATTRIBUTE, new NitfValue(primeId));
    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) NitfAttribute(org.codice.alliance.transformer.nitf.common.NitfAttribute) TreEntryImpl(org.codice.imaging.nitf.core.tre.impl.TreEntryImpl)

Example 9 with NitfAttribute

use of org.codice.alliance.transformer.nitf.common.NitfAttribute in project alliance by codice.

the class ImageInputTransformerTest method assertDateAttribute.

private static void assertDateAttribute(String reason, Metacard metacard, NitfAttribute nitfAttribute, DateTime... expectedDateTimes) {
    for (AttributeDescriptor attributeDescriptor : (Set<AttributeDescriptor>) nitfAttribute.getAttributeDescriptors()) {
        final Attribute attribute = metacard.getAttribute(attributeDescriptor.getName());
        assertDateAttribute(reason, attribute, expectedDateTimes);
    }
}
Also used : Set(java.util.Set) AimidbAttribute(org.codice.alliance.transformer.nitf.common.AimidbAttribute) PiatgbAttribute(org.codice.alliance.transformer.nitf.common.PiatgbAttribute) NitfAttribute(org.codice.alliance.transformer.nitf.common.NitfAttribute) Attribute(ddf.catalog.data.Attribute) ExpltbAttribute(org.codice.alliance.transformer.nitf.common.ExpltbAttribute) IndexedPiaprdAttribute(org.codice.alliance.transformer.nitf.common.IndexedPiaprdAttribute) NitfHeaderAttribute(org.codice.alliance.transformer.nitf.common.NitfHeaderAttribute) PiaprdAttribute(org.codice.alliance.transformer.nitf.common.PiaprdAttribute) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor)

Aggregations

NitfAttribute (org.codice.alliance.transformer.nitf.common.NitfAttribute)9 Metacard (ddf.catalog.data.Metacard)5 TreUtilityTest (org.codice.alliance.transformer.nitf.TreUtilityTest)5 NitfSegmentsFlow (org.codice.imaging.nitf.fluent.NitfSegmentsFlow)5 NitfParserInputFlowImpl (org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl)5 Test (org.junit.Test)5 File (java.io.File)3 FileInputStream (java.io.FileInputStream)3 InputStream (java.io.InputStream)3 HashMap (java.util.HashMap)3 TreUtilityTest.createImageSegment (org.codice.alliance.transformer.nitf.TreUtilityTest.createImageSegment)3 ImageSegment (org.codice.imaging.nitf.core.image.ImageSegment)3 Tre (org.codice.imaging.nitf.core.tre.Tre)3 TreEntryImpl (org.codice.imaging.nitf.core.tre.impl.TreEntryImpl)3 NitfCreationFlowImpl (org.codice.imaging.nitf.fluent.impl.NitfCreationFlowImpl)3 Attribute (ddf.catalog.data.Attribute)1 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)1 Set (java.util.Set)1 AimidbAttribute (org.codice.alliance.transformer.nitf.common.AimidbAttribute)1 ExpltbAttribute (org.codice.alliance.transformer.nitf.common.ExpltbAttribute)1