rpftochandler.java
来自「OpenMap是一个基于JavaBeansTM的开发工具包。利用OpenMap你」· Java 代码 · 共 1,288 行 · 第 1/4 页
JAVA
1,288 行
if (DEBUG_RPFTOCDETAIL) { Debug.output("RpfTocHandler: parseToc(): should be 132: " + boundaryRecordLength); } if (DEBUG_RPFTOCDETAIL) { Debug.output("RpfTocHandler: parseToc(): fseek to Boundary Rectangle Table: " + locations[1].componentLocation); } binFile.seek(locations[1].componentLocation); entries = new RpfTocEntry[numBoundaries]; // Read Boundary rectangle records for (int i = 0; i < n; i++) { if (DEBUG_RPFTOCDETAIL) { Debug.output("RpfTocHandler: parseToc(): read boundary rec#: " + i); } // All this stuff moved to RpfTocEntry.java - DFD // 8/18/99 entries[i] = new RpfTocEntry(binFile, tocNumber, i); if (DEBUG_RPFTOCDETAIL) { Debug.output("RpfTocHandler: parseToc(): entry " + i + " has scale " + entries[i].scale + ", type " + (entries[i].Cib ? "CIB" : "CADRG") + " in zone " + entries[i].zone); if (entries[i].Cib) Debug.output("RpfTocHandler: parseToc(): entry noted as a Cib entry."); } } if (DEBUG_RPFTOCDETAIL) { Debug.output("RpfTocHandler: parseToc(): Read frame file index section subheader at loc: " + locations[2].componentLocation); } // Read # of frame file index records // Skip 1 byte security classification // locations[2] is loc of frame file index section // subheader binFile.seek(locations[2].componentLocation + 1); // NEW long frameIndexTableOffset = (long) binFile.readInteger(); numFrameIndexRecords = (long) binFile.readInteger(); int numPathnameRecords = (int) binFile.readShort(); // indexRecordLength should now be 33, not 35 indexRecordLength = (int) binFile.readShort(); if (DEBUG_RPFTOCDETAIL) { Debug.output("RpfTocHandler: parseToc(): frameIndexTableOffset: " + frameIndexTableOffset); Debug.output("RpfTocHandler: parseToc(): # Frame file index recs: " + numFrameIndexRecords); Debug.output("RpfTocHandler: parseToc(): # pathname records: " + numPathnameRecords); Debug.output("RpfTocHandler: parseToc(): Index rec len(33): " + indexRecordLength); } // In previous version of the RpfTocHandler, we went ahead and read // in all of the RPF frame file paths. For very large collections of // data, expecially with large scale charts and imagery, this turns // out to use a huge amount of data. The code has been reorganized // to skip this part until it's been determined that those files are // actually going to be used by the layer. // readFrameInformation(binFile); // One thing that we still need to do at this point, is query some // of the frame file paths to find out what chart type is being held // for each RpfTocEntry, so during the coverage determination we can // decide whether to use an RpfTocEntry or not. figureOutChartSeriesForEntries(binFile); } catch (IOException ioe) { Debug.error("RpfTocHandler: IO ERROR parsing file!\n\t" + ioe); return false; } catch (FormatException fe) { Debug.error("RpfTocHandler: Format ERROR parsing file!\n\t" + fe); return false; } if (DEBUG_RPFTOC) { Debug.output("LEAVE TOC parsing..."); } return true; } /** * Method that looks at one frame file for each RpfTocEntry, in order to * check the suffix and load the chart series information into the * RpfTocEntry. This is needed for when the RpfTocHandler is asked for * matching RpfTocEntries for a given scale and location when the chart type * has been limited to a certain chart code. * * @param binFile * @throws IOException * @throws FormatException */ protected void figureOutChartSeriesForEntries(BinaryFile binFile) throws IOException, FormatException { RpfTocEntry[] entriesAlreadyChecked = new RpfTocEntry[entries.length]; System.arraycopy(entries, 0, entriesAlreadyChecked, 0, entries.length); // We just need the name of one file, just to see what the series code // is. for (int i = 0; i < numFrameIndexRecords; i++) { // Read frame file index records if (DEBUG_RPFTOCFRAMEDETAIL) { Debug.output("RpfTocHandler: parseToc(): Read frame file index rec #: " + i); } // Index_subhdr_len (9) instead of table_offset (11) // indexRecordLength (33) instead of 35 // componentLocation, not index // locations[3] is frame file index table subsection binFile.seek(locations[3].componentLocation + indexRecordLength * i); int boundaryId = (int) binFile.readShort(); if (DEBUG_RPFTOCFRAMEDETAIL) { Debug.output("boundary id for frame: " + i + " is " + boundaryId); } if (boundaryId > numBoundaries - 1) { throw new FormatException("Bad boundary id in FF index record " + i); } RpfTocEntry entry = entriesAlreadyChecked[boundaryId]; if (entry == null) { continue; // already checked. } else { entriesAlreadyChecked[boundaryId] = null; } /* int frameRow = (int) */binFile.readShort(); /* int frameCol = (int) */binFile.readShort(); /* long pathOffset = (long) */binFile.readInteger(); String filename = binFile.readFixedLengthString(12); // Figure out the chart series ID int dot = filename.lastIndexOf('.'); // Interned so we can look it up in the catalog // later... entry.setInfo(filename.substring(dot + 1, dot + 3).intern()); } /* for i = numFrameIndexRecords */ } /** * Should be called by the RpfFrameCacheHandler before any frame files are * loaded from a RpfTocEntry. The RpfFrameCacheHandler should ask the * RpfTocEntry if the frames have been loaded, and call this if they have * not. */ protected void loadFrameInformation(RpfTocEntry rpfTocEntry) { try { if (binFile == null && aTocFilePath != null) { binFile = new BinaryBufferedFile(aTocFilePath); binFile.byteOrder(aTocByteOrder); readFrameInformation(binFile, rpfTocEntry); binFile.close(); binFile = null; } } catch (IOException ioe) { Debug.error("RpfTocHandler: IO ERROR parsing file for frame information!\n\t" + ioe); } catch (FormatException fe) { Debug.error("RpfTocHandler: Format ERROR parsing file for frame information!\n\t" + fe); } } /** * Reads the BinaryFile to retrieve the Frame file information for the * entry. * * @param binFile a valid, open BinaryFile. * @param entry the RpfTocEntry to fill. * @throws IOException * @throws FormatException */ protected void readFrameInformation(BinaryFile binFile, RpfTocEntry entry) throws IOException, FormatException { int boundaryId, frameRow, frameCol; // ushort int currentPosition; int pathLength; long pathOffset; // uint, offset of frame file pathname RpfFrameEntry frame; int currentBoundaryIdForEntry = entry.coverage.entryNumber; // Read frame file index records for (int i = 0; i < numFrameIndexRecords; i++) { if (DEBUG_RPFTOCFRAMEDETAIL) { Debug.output("RpfTocHandler: parseToc(): Read frame file index rec #: " + i); } // Index_subhdr_len (9) instead of table_offset (11) // indexRecordLength (33) instead of 35 // componentLocation, not index // locations[3] is frame file index table subsection binFile.seek(locations[3].componentLocation + indexRecordLength * i); boundaryId = (int) binFile.readShort(); if (boundaryId != currentBoundaryIdForEntry) { // Only load the frame names of the entry we are using... continue; } if (DEBUG_RPFTOCFRAMEDETAIL) { Debug.output("boundary id for frame: " + i + " is " + boundaryId); } // DKS NEW: changed from 1 to 0 to agree w/ spec. -1 // added also. // if (boundaryId < 0 || boundaryId > numBoundaries - // 1 ) if (boundaryId > numBoundaries - 1) { throw new FormatException("Bad boundary id in FF index record " + i); } frameRow = (int) binFile.readShort(); frameCol = (int) binFile.readShort(); // DKS. switched from horizFrames to vertFrames // DKS NEW: CHANGED FROM 1 to 0 to agree w/spec. ALSO // COL below // if (frameRow < 1 || frameRow > entry->vertFrames) if (frameRow > entry.vertFrames - 1) { throw new FormatException("Bad row number: " + frameRow + ", in FF index record " + i + ", Min row num=0; Max. row num:" + (entry.horizFrames - 1)); } // DKS. switched from vertFrames to horizFrames if (frameCol > entry.horizFrames - 1) { throw new FormatException(" Bad col number in FF index record " + i); } // DKS NEW: -1 removed on frameRow, col // JRB // frame = &entry->frames[frameRow][frameCol]; // [(entry->vertFrames - 1L)-frameRow] flips the array // over, so that the frames can be referenced // correctly from the top left, instead of the // specification notation of bottom left. frame = entry.getFrame((entry.vertFrames - 1) - frameRow, frameCol); if (frame.exists && DEBUG_RPFTOCDETAIL) { Debug.output("FF " + i + " is a duplicate"); } // DKS: phys_loc deleted // pathname offset pathOffset = (long) binFile.readInteger(); if (pathOffset < 0) { continue; } // Save file position for later currentPosition = (int) binFile.getFilePointer(); // Go to start of pathname record // DKS. New pathOffset offset from start of frame file // index section of TOC?? // DKS. Add pathoffset wrt frame file index table // subsection (loc[3]) binFile.seek(locations[3].componentLocation + pathOffset); pathLength = (int) binFile.readShort(); if (DEBUG_RPFTOCFRAMEDETAIL) { Debug.output("RpfTocHandler: parseToc(): pathLength:" + pathLength); } // 1st part of directory name is passed as arg: // e.g. "../RPF2/" String rpfdir = dir; StringBuffer sBuf = new StringBuffer(pathLength); // read rest of directory name from toc // DKS: skip 1st 2 chars: "./": String pathTest = binFile.readFixedLengthString(2); if (pathTest.equals("./")) { fullPathsInATOC = false; } else { fullPathsInATOC = true; } if (!fullPathsInATOC) { // DKS: Make up for skipped 2 chars sBuf.append(binFile.readFixedLengthString(pathLength - 2)); } else { sBuf.append(pathTest); sBuf.append(binFile.readFixedLengthString(pathLength - 2)); } // Add the trim because it looks like NIMA doesn't // always get the pathLength correct... String directory = sBuf.toString().trim(); if (DEBUG_RPFTOCFRAMEDETAIL) {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?