📄 rpfattributes.java
字号:
// **********************************************************************// // <copyright>// // BBN Technologies// 10 Moulton Street// Cambridge, MA 02138// (617) 873-8000// // Copyright (C) BBNT Solutions LLC. All rights reserved.// // </copyright>// **********************************************************************// // $Source: /cvs/distapps/openmap/src/openmap/com/bbn/openmap/layer/rpf/RpfAttributes.java,v $// $RCSfile: RpfAttributes.java,v $// $Revision: 1.3.2.1 $// $Date: 2004/10/14 18:27:14 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.layer.rpf;import java.io.IOException;import java.io.FileNotFoundException;import com.bbn.openmap.io.BinaryBufferedFile;import com.bbn.openmap.io.BinaryFile;import com.bbn.openmap.io.FormatException;import com.bbn.openmap.util.Debug;/** * This class knows how to read the attribute section of an RPF file. * This section includes all the information about the image, * including source and production information. */public class RpfAttributes { public String currencyDate;// [8]; public String productionDate; // [8]; public String significantDate; // [8]; public String chartSeriesCode; // [10]; public String mapDesignationCode; // [8]; public String oldHorDatum; // [4]; public String edition; // [7]; public String projectionCode; // [2]; public float projectionA; public float projectionB; public float projectionC; public float projectionD; public String vertDatumCode; // [4]; public String horDatumCode; // [4]; public long vertAbsAccuracy; //uint public int vertAbsUnits; //ushort public long horAbsAccuracy; //uint public int horAbsUnits; // ushort public long vertRelAccuracy; //uint public int vertRelUnits; // ushort public long horRelAccuracy; //uint public int horRelUnits; // ushort public String ellipsoidCode; // [3]; public String soundingDatumCode; // [4]; public int navSystemCode; // ushort public String gridCode; // [2]; public float eMagChange; public int eMagChangeUnits; // ushort public float wMagChange; public int wMagChangeUnits; // ushort public float magAngle; //uint public int magAngleUnits; // ushort public float gridConver; //uint public int gridConverUnits; // ushort public double highElevation; public int highElevationUnits; // ushort public double highLat; public double highLon; public String legendFileName; // [12]; public String dataSource; // [12]; public long gsd; // uint public int dataLevel; // ushort public RpfAttributes() {} /** * Read the section in a file. The method will start reading from * the offset provided. * * @param binFile the opened RPF file. * @param attributeLocation the offset of the attribute section in * the file. */ public boolean read(BinaryFile binFile, long attributeLocation) { try { long k; long j = 0; AttributeSubheader attributeSubheader = new AttributeSubheader(); // AttributeOffsetRecord attributeOffsetRecord = new // AttributeOffsetRecord(); AttributeOffsetRecord attributeOffsetRecord; binFile.seek(attributeLocation); attributeSubheader.read(binFile); if (Debug.debugging("rpfdetail")) { System.out.println(attributeSubheader); } AttributeOffsetRecord[] attributeOffsetRecords = new AttributeOffsetRecord[attributeSubheader.numAttributes]; int i = attributeSubheader.numAttributes - 1; // OK, I know what you are thinking - two sequential // loops? It's an optimization for the binFile, // especially if we're reading from a URL - turns this // into a couple of sequential reads. j = 0; for (int attIndex = attributeSubheader.numAttributes; attIndex > 0; attIndex--) { i = attIndex - 1; k = attributeLocation + 10/* sizeof(attribute_subheader) */ + attributeSubheader.tableOffset + ((attributeSubheader.numAttributes - attIndex) * 8/* sizeof(attributeOffsetRecord */); binFile.seek(k); attributeOffsetRecords[i] = new AttributeOffsetRecord(); attributeOffsetRecords[i].read(binFile); if (Debug.debugging("rpfdetail")) { Debug.output(" ##" + (++j) + " at " + k + " => attrib ID '" + attributeOffsetRecords[i].attributeId + "'|Param ID '" + attributeOffsetRecords[i].parameterId + "'|offset '" + attributeOffsetRecords[i].offset + "'"); } } for (i = attributeOffsetRecords.length - 1; i >= 0; i--) { attributeOffsetRecord = attributeOffsetRecords[i]; binFile.seek(attributeLocation + 10 + attributeOffsetRecord.offset); switch (attributeOffsetRecord.attributeId) { case 1: currencyDate = binFile.readFixedLengthString(8);// [8]; break; case 2: productionDate = binFile.readFixedLengthString(8); // [8]; break; case 3: significantDate = binFile.readFixedLengthString(8); // [8]; break; case 4: if ((int) attributeOffsetRecord.parameterId == 1) chartSeriesCode = binFile.readFixedLengthString(10); // [10]; else if ((int) attributeOffsetRecord.parameterId == 2) mapDesignationCode = binFile.readFixedLengthString(8); // [8]; else if ((int) attributeOffsetRecord.parameterId == 3) oldHorDatum = binFile.readFixedLengthString(4); // [4]; else if ((int) attributeOffsetRecord.parameterId == 4) edition = binFile.readFixedLengthString(7); // [7]; break; case 5: if ((int) attributeOffsetRecord.parameterId == 1) projectionCode = binFile.readFixedLengthString(2); // [2]; else if ((int) attributeOffsetRecord.parameterId == 2) projectionA = binFile.readFloat(); else if ((int) attributeOffsetRecord.parameterId == 3) projectionB = binFile.readFloat(); else if ((int) attributeOffsetRecord.parameterId == 4) projectionC = binFile.readFloat(); else if ((int) attributeOffsetRecord.parameterId == 5) projectionD = binFile.readFloat(); break; case 6: vertDatumCode = binFile.readFixedLengthString(4); // [4]; break; case 7: horDatumCode = binFile.readFixedLengthString(4); // [4]; break; case 8: if ((int) attributeOffsetRecord.parameterId == 1) vertAbsAccuracy = (long) binFile.readInteger(); else if ((int) attributeOffsetRecord.parameterId == 2) vertAbsUnits = (int) binFile.readShort(); //ushort break; case 9: if ((int) attributeOffsetRecord.parameterId == 1) horAbsAccuracy = (long) binFile.readInteger(); else if ((int) attributeOffsetRecord.parameterId == 2) horAbsUnits = (int) binFile.readShort(); // ushort break; case 10: if ((int) attributeOffsetRecord.parameterId == 1) vertRelAccuracy = (long) binFile.readInteger(); else if ((int) attributeOffsetRecord.parameterId == 2) vertRelUnits = (int) binFile.readShort(); // ushort break; case 11: if ((int) attributeOffsetRecord.parameterId == 1) horRelAccuracy = (long) binFile.readInteger(); else if ((int) attributeOffsetRecord.parameterId == 2) horRelUnits = (int) binFile.readShort(); // ushort break; case 12: ellipsoidCode = binFile.readFixedLengthString(3); // [3]; break; case 13: soundingDatumCode = binFile.readFixedLengthString(4); // [4]; break; case 14: navSystemCode = (int) binFile.readShort(); // ushort break; case 15: gridCode = binFile.readFixedLengthString(2); // [2];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -