Пример #1
0
        private void parseFrameFileIndexAndPathnameTables(java.nio.ByteBuffer buffer)
        {
            int theSectionOffset = buffer.position();
            Hashtable <Integer, String> pathnames = new Hashtable <Integer, String>();

            for (int i = 0; i < this.numOfFrameFileIndexRecords; i++)
            {
                this.frameFileIndexTable.add(new RPFFrameFileIndexRecord(buffer));
            }

            for (int i = 0; i < this.numOfPathnameRecords; i++)
            {
                int relOffset = buffer.position() - theSectionOffset;
                int len       = NITFSUtil.getUShort(buffer);
                pathnames.put(relOffset, NITFSUtil.getString(buffer, len));
            }

            if (0 < this.frameFileIndexTable.size() && 0 < pathnames.size())
            { // update pathname field in every RPFFrameFileIndexRecord
                foreach (RPFFrameFileIndexRecord rec in this.frameFileIndexTable)
                {
                    int offset = (int)rec.getPathnameRecordOffset();
                    if (pathnames.containsKey(offset))
                    {
                        rec.setPathname(pathnames.get(offset));
                    }
                    else
                    {
                        throw new NITFSRuntimeException("NITFSReader.CorrespondingPathnameWasNotFound");
                    }
                }
            }
        }
Пример #2
0
        private void parseColorGrayscaleSection(java.nio.ByteBuffer buffer)
        {
            buffer.position(this.componentLocationTable.getColorGrayscaleSectionSubheaderLocation());

            this.numOfColorGrayscaleOffsetRecords = NITFSUtil.getByteAsShort(buffer);
            this.numOfColorConverterOffsetRecords = NITFSUtil.getByteAsShort(buffer);
            this.externalColorGrayscaleFilename   = NITFSUtil.getString(buffer, 12);
        }
        public NITFSUserDefinedHeaderSegment(java.nio.ByteBuffer buffer)
        {
            base(NITFSSegmentType.USER_DEFINED_HEADER_SEGMENT, buffer, 0, 0, 0, 0);

            this.headerLength = Integer.parseInt(NITFSUtil.getString(buffer, 5));
            this.overflow     = Integer.parseInt(NITFSUtil.getString(buffer, 3));
            this.dataTag      = NITFSUtil.getString(buffer, 6);
            this.dataLength   = Integer.parseInt(NITFSUtil.getString(buffer, 5));
        }
Пример #4
0
 private void parseRPFColorOffsetRecord(java.nio.ByteBuffer buffer)
 {
     this.tableID               = NITFSUtil.getUShort(buffer);
     this.numOfColorRecords     = NITFSUtil.getUInt(buffer);
     this.colorElementLength    = NITFSUtil.getByteAsShort(buffer);
     this.histogramRecordLength = NITFSUtil.getUShort(buffer);
     this.colorTableOffset      = NITFSUtil.getUInt(buffer);
     this.histogramTableOffset  = NITFSUtil.getUInt(buffer);
 }
Пример #5
0
        public RPFBoundingRectangleSection(ByteBuffer buffer)
        {
            // [ bounding rectangle section subheader ]
            this.tableOffset     = NITFSUtil.getUInt(buffer);
            this.numberOfRecords = NITFSUtil.getUShort(buffer);
            this.recordLength    = NITFSUtil.getUShort(buffer);

            parseBoundsRecords(buffer);
        }
Пример #6
0
//    public ArrayList<String> getPathnameTable()
//    {
//        return pathnameTable;
//    }

        public RPFFrameFileIndexSection(java.nio.ByteBuffer buffer)
        {
            // [ frame file index section subheader ]
            this.highestSecurityClassification = NITFSUtil.getString(buffer, 1);
            this.frameFileIndexTableOffset     = NITFSUtil.getUInt(buffer);
            this.numOfFrameFileIndexRecords    = NITFSUtil.getUInt(buffer);
            this.numOfPathnameRecords          = NITFSUtil.getUShort(buffer);
            this.frameFileIndexRecordLength    = NITFSUtil.getUShort(buffer);

            this.parseFrameFileIndexAndPathnameTables(buffer);
        }
Пример #7
0
            private String pathname; // this field is not part of the NITFS spec

            public RPFFrameFileIndexRecord(java.nio.ByteBuffer buffer)
            {
                this.boundaryRectangleRecordNumber = NITFSUtil.getUShort(buffer);
                this.frameLocationRowNumber        = NITFSUtil.getUShort(buffer);
                this.frameLocationColumnNumber     = NITFSUtil.getUShort(buffer);
                this.pathnameRecordOffset          = NITFSUtil.getUInt(buffer);
                this.frameFileName       = NITFSUtil.getString(buffer, 12);
                this.geoLocation         = NITFSUtil.getString(buffer, 6);
                this.securityClass       = NITFSUtil.getString(buffer, 1);
                this.securityCountryCode = NITFSUtil.getString(buffer, 2);
                this.securityReleaseMark = NITFSUtil.getString(buffer, 2);
                this.pathname            = "";
            }
Пример #8
0
 private void parseImageDescriptionSubheader(java.nio.ByteBuffer buffer)
 {
     this.numOfSpectralGroups                 = NITFSUtil.getUShort(buffer);
     this.numOfSubframeTables                 = NITFSUtil.getUShort(buffer);
     this.numOfSpectralBandTables             = NITFSUtil.getUShort(buffer);
     this.numOfSpectralBandLinesPerImageRow   = NITFSUtil.getUShort(buffer);
     this.numOfSubframesInEastWestDirection   = NITFSUtil.getUShort(buffer);
     this.numOfSubframesInNorthSouthDirection = NITFSUtil.getUShort(buffer);
     this.numOfOutputColumnsPerSubframe       = NITFSUtil.getUInt(buffer);
     this.numOfOutputRowsPerSubframe          = NITFSUtil.getUInt(buffer);
     this.subframeMaskTableOffset             = NITFSUtil.getUInt(buffer);
     this.transparencyMaskTableOffset         = NITFSUtil.getUInt(buffer);
 }
Пример #9
0
 public RPFHeaderSection(java.nio.ByteBuffer buffer)
 {
     this.endianIndicator         = ((byte)0 != buffer.get());        // reads 1 byte, 0 for big endian
     this.headerLength            = buffer.getShort();                // reads 2 bytes
     this.filename                = NITFSUtil.getString(buffer, 12);
     this.updateIndicator         = NITFSUtil.getByteAsShort(buffer); // reads 1 byte (short)
     this.govSpecNumber           = NITFSUtil.getString(buffer, 15);
     this.govSpecDate             = NITFSUtil.getString(buffer, 8);
     this.securityClass           = NITFSUtil.getString(buffer, 1);
     this.securityCountryCode     = NITFSUtil.getString(buffer, 2);
     this.securityReleaseMark     = NITFSUtil.getString(buffer, 2);
     this.locationSectionLocation = buffer.getInt();        // read 4 bytes (int)
 }
Пример #10
0
        private void parseFileHeaderInfo(java.nio.ByteBuffer buffer)
        {
            this.headerID             = NITFSUtil.getString(buffer, 0, 4);
            this.version              = NITFSUtil.getString(buffer, 5);
            this.isVersion0210        = "02.10".Equals(version);
            this.complexityLevel      = NITFSUtil.getShortNumeric(buffer, 2);
            this.specialType          = NITFSUtil.getString(buffer, 4);          // offset  11, size 4
            this.originationStationId = NITFSUtil.getString(buffer, 10);         // offset  15, size 10
            this.dateTime             = NITFSUtil.getString(buffer, 14);         // offset  25, size 14
            this.title = NITFSUtil.getString(buffer, 80);                        // offset  39, size 80

            this.FSCLAS = NITFSUtil.getString(buffer, 1);                        // offset 119, size 1
            this.FSCLSY = (isVersion0210 ? NITFSUtil.getString(buffer, 2) : ""); // offset 120, size 2
            this.FSCODE = NITFSUtil.getString(buffer, isVersion0210 ? 11 : 40);
            this.FSCTLH = NITFSUtil.getString(buffer, isVersion0210 ? 2 : 40);
            this.FSREL  = NITFSUtil.getString(buffer, isVersion0210 ? 20 : 40);

            this.FSDCTP = (isVersion0210 ? NITFSUtil.getString(buffer, 2) : "");
            this.FSDCDT = (isVersion0210 ? NITFSUtil.getString(buffer, 8) : "");   // offset 157/
            this.FSDCXM = (isVersion0210 ? NITFSUtil.getString(buffer, 4) : "");   // offset 165/
            this.FSDG   = (isVersion0210 ? NITFSUtil.getString(buffer, 1) : "");   // offset 169/
            this.FSDGDT = (isVersion0210 ? NITFSUtil.getString(buffer, 8) : "");   // oofset 170/
            this.FSCLTX = (isVersion0210 ? NITFSUtil.getString(buffer, 43) : "");  // offset 178/
            this.FSCATP = (isVersion0210 ? NITFSUtil.getString(buffer, 1) : "");   // offset 221/

            this.FSCAUT = NITFSUtil.getString(buffer, isVersion0210 ? 40 : 20);    // offset 222/240

            this.FSCRSN = (isVersion0210 ? NITFSUtil.getString(buffer, 1) : "");   // offset 262/
            this.FSSRDT = (isVersion0210 ? NITFSUtil.getString(buffer, 8) : "");   // offset 263/
            this.FSCTLN = NITFSUtil.getString(buffer, isVersion0210 ? 15 : 20);    // offset 271/260
            this.FSDWNG = (isVersion0210) ? "" : NITFSUtil.getString(buffer, 6);   // offset    /280

            this.FSDEVT = (!isVersion0210 && "999998".Equals(FSDWNG))              // offset    /286
                            ? NITFSUtil.getString(buffer, 40) : "";

            this.FSCOP  = NITFSUtil.getString(buffer, 5);                             // offset 286/+40
            this.FSCPYS = NITFSUtil.getString(buffer, 5);                             // offset 291/+40
            this.ENCRYP = NITFSUtil.getString(buffer, 1);                             // offset 296/+40

            this.FBKGC  = (isVersion0210 ? NITFSUtil.getString(buffer, 297, 3) : ""); // offset 297/
            this.ONAME  = NITFSUtil.getString(buffer, isVersion0210 ? 24 : 27);       // offset 300/297(+40)
            this.OPHONE = NITFSUtil.getString(buffer, 18);                            // offset 324(+40)

            this.fileLength   = NITFSUtil.getNumeric(buffer, 12);                     // offset 342(+40)
            this.headerLength = NITFSUtil.getNumeric(buffer, 6);                      // offset 352(+40)
        }
Пример #11
0
        private void parseColormapSubSection(java.nio.ByteBuffer buffer)
        {
            buffer.position(this.componentLocationTable.getColormapSubsectionLocation());

            this.colormapOffsetTableOffset           = NITFSUtil.getUInt(buffer);
            this.colormapGrayscaleOffsetRecordLength = NITFSUtil.getUShort(buffer);
            // read color / grayscale AND histogram records; builds a ColorMap (LUT)
            if (0 < this.numOfColorGrayscaleOffsetRecords)
            {
                rpfColorMaps = new RPFColorMap[this.numOfColorGrayscaleOffsetRecords];
                for (int i = 0; i < this.numOfColorGrayscaleOffsetRecords; i++)
                {
                    rpfColorMaps[i] = new RPFColorMap(buffer, this.componentLocationTable.getColormapSubsectionLocation());
                }
            }
            else
            {
                throw new NITFSRuntimeException("NITFSReader.InvalidNumberOfRPFColorGrayscaleRecords");
            }
        }
Пример #12
0
        public NITFSImageBand(java.nio.ByteBuffer buffer)
        {
            this.representation = NITFSUtil.getString(buffer, 2);
            this.significanceForImageCategory = NITFSUtil.getString(buffer, 6);
            this.imageFilterCondition         = NITFSUtil.getString(buffer, 1);
            this.stdImageFilterCode           = NITFSUtil.getString(buffer, 3);
            this.numOfLookupTables            = NITFSUtil.getShortNumeric(buffer, 1);
            this.numOfLookupTableEntries      = NITFSUtil.getShortNumeric(buffer, 5);
            if (0 < this.numOfLookupTables && 0 < this.numOfLookupTableEntries)
            {
                this.lut = new byte[this.numOfLookupTables][this.numOfLookupTableEntries];
                for (int j = 0; j < this.numOfLookupTables; j++)
                {
                    buffer.get(this.lut[j], 0, this.numOfLookupTableEntries);
                }
            }

            this.isGrayImage         = (1 == this.numOfLookupTables);
            this.hasTransparentEntry = (217 == this.numOfLookupTableEntries);
        }
Пример #13
0
        public RPFLocationSection(java.nio.ByteBuffer buffer)
        {
            this.locationSectionLength         = NITFSUtil.getUShort(buffer);
            this.componentLocationTableOffset  = NITFSUtil.getUInt(buffer);
            this.numOfComponentLocationRecords = NITFSUtil.getUShort(buffer);
            this.componentLocationRecordLength = NITFSUtil.getUShort(buffer);
            this.componentAggregateLength      = NITFSUtil.getUInt(buffer);

            if (this.numOfComponentLocationRecords < 2)
            {
                throw new NITFSRuntimeException("NITFSReader:InvalidNumberOfComponentLocationRecords");
            }

            for (int i = 0; i < this.numOfComponentLocationRecords; i++)
            {
                int id = NITFSUtil.getUShort(buffer);
                table.put(id, new ComponentLocationRecord(id,
                                                          NITFSUtil.getUInt(buffer), // read uint:4 as "length"
                                                          NITFSUtil.getUInt(buffer)  // read uint:4 as "location"
                                                          ));
            }
        }
Пример #14
0
 public RPFBoundingRectangleRecord(ByteBuffer buffer)
 {
     this.dataType         = NITFSUtil.getString(buffer, 5);
     this.compressionRatio = NITFSUtil.getString(buffer, 5);
     this.scale            = NITFSUtil.getString(buffer, 12);
     this.zone             = NITFSUtil.getString(buffer, 1);
     this.producer         = NITFSUtil.getString(buffer, 5);
     this.ulLat            = buffer.getDouble();
     this.ulLon            = buffer.getDouble();
     this.llLat            = buffer.getDouble();
     this.llLon            = buffer.getDouble();
     this.urLat            = buffer.getDouble();
     this.urLon            = buffer.getDouble();
     this.lrLat            = buffer.getDouble();
     this.lrLon            = buffer.getDouble();
     this.nsRes            = buffer.getDouble();
     this.ewRes            = buffer.getDouble();
     this.latInterval      = buffer.getDouble();
     this.lonInterval      = buffer.getDouble();
     this.numFramesNS      = NITFSUtil.getUInt(buffer);
     this.numFramesEW      = NITFSUtil.getUInt(buffer);
 }
Пример #15
0
 public RelatedImagesSection(java.nio.ByteBuffer buffer)
 {
     this.relatedImageDescriptionTableOffset  = NITFSUtil.getUInt(buffer);
     this.numOfRelatedImageDescriptionRecords = NITFSUtil.getUShort(buffer);
     this.relatedImageDescriptionRecordLength = NITFSUtil.getUShort(buffer);
 }