⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rpfattributes.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                    break;                case 16:                    if ((int) attributeOffsetRecord.parameterId == 1)                        eMagChange = binFile.readFloat();                    else if ((int) attributeOffsetRecord.parameterId == 2)                        eMagChangeUnits = (int) binFile.readShort(); // ushort                    break;                case 17:                    if ((int) attributeOffsetRecord.parameterId == 1)                        wMagChange = binFile.readFloat();                    else if ((int) attributeOffsetRecord.parameterId == 2)                        wMagChangeUnits = (int) binFile.readShort(); // ushort                    break;                case 18:                    if ((int) attributeOffsetRecord.parameterId == 1)                        magAngle = binFile.readFloat();                    else if ((int) attributeOffsetRecord.parameterId == 2)                        magAngleUnits = (int) binFile.readShort(); // ushort                    break;                case 19:                    if ((int) attributeOffsetRecord.parameterId == 1)                        gridConver = binFile.readFloat();                    else if ((int) attributeOffsetRecord.parameterId == 2)                        gridConverUnits = (int) binFile.readShort(); // ushort                    break;                case 20:                    if ((int) attributeOffsetRecord.parameterId == 1)                        highElevation = binFile.readDouble();                    else if ((int) attributeOffsetRecord.parameterId == 2)                        highElevationUnits = (int) binFile.readShort(); // ushort                    else if ((int) attributeOffsetRecord.parameterId == 3)                        highLat = binFile.readDouble();                    else if ((int) attributeOffsetRecord.parameterId == 4)                        highLon = binFile.readDouble();                    break;                case 21:                    legendFileName = binFile.readFixedLengthString(12); // [12];                    break;                case 22:                    if ((int) attributeOffsetRecord.parameterId == 1)                        dataSource = binFile.readFixedLengthString(12); // [12];                    else if ((int) attributeOffsetRecord.parameterId == 2)                        gsd = (long) binFile.readInteger(); // uint                    break;                case 23:                    dataLevel = (int) binFile.readShort(); // ushort                    break;                }                i--;            }        } catch (IOException e) {            Debug.error("RpfAttributes: read(): File IO Error!\n" + e);            return false;        } catch (FormatException f) {            Debug.error("RpfAttributes: read(): File IO Format error!\n" + f);            return false;        }        return true;    }    public String toString() {        StringBuffer s = new StringBuffer();        s.append("Attribute Section:\n");        s.append(" currency date = " + currencyDate + "\n");        s.append(" production date = " + productionDate + "\n");        s.append(" significant date = " + significantDate + "\n");        s.append(" chart series code = " + chartSeriesCode + "\n");        s.append(" map designation code = " + mapDesignationCode + "\n");        s.append(" old horizontal datum = " + oldHorDatum + "\n");        s.append(" edition = " + edition + "\n");        s.append(" projection code = " + projectionCode + "\n");        s.append(" projection A = " + projectionA + "\n");        s.append(" projection B = " + projectionB + "\n");        s.append(" projection C = " + projectionC + "\n");        s.append(" projection D = " + projectionD + "\n");        s.append(" vertical datum code = " + vertDatumCode + "\n");        s.append(" horizontal datum code = " + horDatumCode + "\n");        s.append(" vertical absolute accuracy = " + vertAbsAccuracy + "\n");        s.append(" vertical absolute units = " + vertAbsUnits + "\n");        s.append(" horizontal absolute accuracy = " + horAbsAccuracy + "\n");        s.append(" horizontal absolute units = " + horAbsUnits + "\n");        s.append(" vertical relative accuracy = " + vertRelAccuracy + "\n");        s.append(" vertical relative units = " + vertRelUnits + "\n");        s.append(" horizontal relative accuracy = " + horRelAccuracy + "\n");        s.append(" horizontal relative units = " + horRelUnits + "\n");        s.append(" ellipoid code = " + ellipsoidCode + "\n");        s.append(" sounding datum code = " + soundingDatumCode + "\n");        s.append(" nav system code = " + navSystemCode + "\n");        s.append(" grid code = " + gridCode + "\n");        s.append(" east mag change = " + eMagChange + "\n");        s.append(" east mag change units = " + eMagChangeUnits + "\n");        s.append(" west mag change = " + wMagChange + "\n");        s.append(" west mag units = " + wMagChangeUnits + "\n");        s.append(" magnetic angle = " + magAngle + "\n");        s.append(" magnetic angle units = " + magAngleUnits + "\n");        s.append(" grid conversion = " + gridConver + "\n");        s.append(" grid conversion units = " + gridConverUnits + "\n");        s.append(" high elevation = " + highElevation + "\n");        s.append(" high elevation units = " + highElevationUnits + "\n");        s.append(" high latitude = " + highLat + "\n");        s.append(" high longitude = " + highLon + "\n");        s.append(" legend file name = " + legendFileName + "\n");        s.append(" data source = " + dataSource + "\n");        s.append(" gsd = " + gsd + "\n");        s.append(" data level = " + dataLevel + "\n");        return s.toString();    }    /**     * Get the attributes from within a RPF Frame file. Returns null     * if something goes wrong. You do need to make sure that the     * Debug class is initialized before calling this class. For     * OpenMap, it usually is.     *      * @param filename the file path for the RPF frame file.     * @return a RpfAttributes object.     */    public static RpfAttributes getAttributes(String filename)            throws IOException, FileNotFoundException {        BinaryFile binFile = new BinaryBufferedFile(filename);        RpfHeader head = new RpfHeader();        head.read(binFile);        RpfAttributes att = getAttributes(binFile);        binFile.close();        head = null;        return att;    }    /**     * Get the attributes from within a RPF Frame file, after the     * header has been read. Returns null if something goes wrong. You     * do need to make sure that the Debug class is initialized before     * calling this class. For OpenMap, it usually is.     *      * @param binFile BinaryFile.     * @return a RpfAttributes object.     */    public static RpfAttributes getAttributes(BinaryFile binFile)            throws IOException, FileNotFoundException {        RpfFileSections rfs = new RpfFileSections(binFile);        RpfAttributes att = rfs.parseAttributes(binFile);        return att;    }    public static void main(String[] args) {        if (args.length != 1) {            System.out.println("Usage: java RpfAttributes <path to RPF frame>");            return;        }        Debug.init(System.getProperties());        try {            RpfAttributes att = RpfAttributes.getAttributes(args[0]);            Debug.output(att.toString());        } catch (FileNotFoundException e) {            Debug.error("RpfAttributes: file " + args[0] + " not found");        } catch (IOException ioe) {            Debug.error("RpfAttributes: File IO Error while handling attributes: \n"                    + ioe);        }    }    static public class AttributeSubheader {        int numAttributes; //ushort        int numArealRecords; // ushort        long tableOffset; // ulong        int offsetRecordLength; // ushort        public void read(BinaryFile binFile) {            try {                numAttributes = (int) binFile.readShort();                numArealRecords = (int) binFile.readShort();                tableOffset = (long) binFile.readInteger();                offsetRecordLength = (int) binFile.readShort();            } catch (IOException e) {                Debug.error("AttributeSubheader: read(): File IO Error!\n" + e);            } catch (FormatException f) {                Debug.error("AttributeSubheader: read(): File IO Format error!\n"                        + f);            }        }        public String toString() {            StringBuffer s = new StringBuffer();            s.append("## RPF ATTRIBUTE INFORMATION\n");            s.append("Number of Attributes - " + numAttributes + "\n");            s.append("Number of Areal Records - " + numArealRecords + "\n");            s.append("Size of offset - " + tableOffset + "\n");            s.append("Record Length - " + offsetRecordLength + "\n");            return s.toString();        }    }    static public class AttributeOffsetRecord {        int attributeId; // ushort        int parameterId; //char        int sequenceNum; //char        long offset; //ulong        public void read(BinaryFile binFile) {            try {                attributeId = (int) binFile.readShort();                parameterId = binFile.read();                sequenceNum = binFile.read();                offset = (long) binFile.readInteger();            } catch (IOException e) {                Debug.error("AttributeOffsetRecord: read(): File IO Error!\n"                        + e);            } catch (FormatException f) {                Debug.error("AttributeOffsetRecord: read(): File IO Format error!\n"                        + f);            }        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -