Package com.bbn.openmap.io

Examples of com.bbn.openmap.io.BinaryBufferedFile


     *            with the file
     */
    public synchronized void finishInitialization() throws FormatException {
        internTableName();
        try {
            inputFile = new BinaryBufferedFile(filename);
        } catch (IOException e) {
            throw new FormatException(e.toString());
        }
        try {
            byte preHeaderLen[] = inputFile.readBytes(4, false);
View Full Code Here


            StringBuffer newf = new StringBuffer(realfname.substring(0,
                    realfname.length() - 1));
            fopen = newf.append("x").toString();
        }

        vli = new DcwVariableLengthIndexFile(new BinaryBufferedFile(fopen), byteorder);
    }
View Full Code Here

     * @see #close()
     */
    public synchronized void reopen(int seekRow) throws FormatException {
        try {
            if (inputFile == null) {
                inputFile = new BinaryBufferedFile(filename);
                inputFile.byteOrder(byteorder);
            }
            if (seekRow > 0) {
                seekToRow(seekRow);
            }
View Full Code Here

     * @exception FormatException some error was encountered in trying
     *            to read the file.
     */
    public DcwVariableLengthIndexFile(String filename, boolean msbfirst)
            throws FormatException, IOException {
        this(new BinaryBufferedFile(filename), msbfirst);
    }
View Full Code Here

     */
    public BinaryFile open(String pszFilename) throws IOException {

        fileName = pszFilename;

        fpDDF = new BinaryBufferedFile(pszFilename);

        // Read the 24 byte leader.
        byte[] achLeader = new byte[DDF_LEADER_SIZE];

        if (fpDDF.read(achLeader) != DDF_LEADER_SIZE) {
View Full Code Here

    }

    public void reopen() {
        try {
            if (fpDDF == null) {
                fpDDF = new BinaryBufferedFile(fileName);
            }
        } catch (IOException ioe) {

        }
    }
View Full Code Here

            Debug.output("Counting code in " + file.getName());

        int count = 0;

        try {
            BinaryBufferedFile bbf = new BinaryBufferedFile(file);

            try {
                while (true) {
                    char c = bbf.readChar();
                    if (c == ';' || c == '}') {
                        count++;
                    }
                }
            } catch (EOFException eofe) {
            } catch (FormatException fe) {
            }
            bbf.close();

            if (DETAIL)
                Debug.output(file.getName() + " has " + count + " LOC");

            sloc += count;
View Full Code Here

        if (shpFileName == null) {
            return null;
        }

        BinaryBufferedFile ssx = new BinaryBufferedFile(ssx(shpFileName));
        if (shp == null) {
            shp = new BinaryBufferedFile(shpFileName);
        }

        // Need to figure out what the shape type is...
        ssx.seek(32);

        // int shapeType = readLEInt(ssx);
        // /
        ssx.byteOrder(false);
        int shapeType = ssx.readInteger();
        // /
        ssx.seek(100); // skip the file header

        while (true) {
            int result = ssx.read(ixRecord, 0, SPATIAL_INDEX_RECORD_LENGTH);
            // if (result == -1) {
            if (result <= 0) {
                break;// EOF
            } else {
                recNum++;
                double xmin2 = readLEDouble(ixRecord, 8);
                double ymin2 = readLEDouble(ixRecord, 16);
                double xmax2 = readLEDouble(ixRecord, 24);
                double ymax2 = readLEDouble(ixRecord, 32);
                if (Debug.debugging("spatialindexdetail")) {
                    Debug.output("Looking at rec num " + recNum);
                    Debug.output("  " + xmin2 + ", " + ymin2 + "\n  " + xmax2
                            + ", " + ymax2);
                }

                if (gatherBounds) {
                    bounds.addPoint(xmin2, ymin2);
                    bounds.addPoint(xmax2, ymax2);
                }

                if (intersects(xmin,
                        ymin,
                        xmax,
                        ymax,
                        xmin2,
                        ymin2,
                        xmax2,
                        ymax2)) {

                    int offset = readBEInt(ixRecord, 0);
                    int byteOffset = offset * 2;
                    int contentLength = readBEInt(ixRecord, 4);
                    int recordSize = (contentLength * 2) + 8;
                    // System.out.print(".");
                    // System.out.flush();

                    if (recordSize < 0) {
                        Debug.error("SpatialIndex: supposed to read record size of "
                                + recordSize);
                        break;
                    }

                    if (recordSize > sRecordSize) {
                        sRecordSize = recordSize;
                        if (Debug.debugging("spatialindexdetail")) {
                            Debug.output("Shapefile SpatialIndex record size: "
                                    + sRecordSize);
                        }
                        sRecord = new byte[sRecordSize];
                    }

                    if (Debug.debugging("spatialindex")) {
                        Debug.output("going to shp byteOffset = " + byteOffset
                                + " for record size = " + recordSize
                                + ", offset = " + offset + ", shape type = "
                                + shapeType);
                    }

                    try {
                        shp.seek(byteOffset);
                        int nBytes = shp.read(sRecord, 0, recordSize);
                        if (nBytes < recordSize) {
                            Debug.error("Shapefile SpatialIndex expected "
                                    + recordSize + " bytes, but got " + nBytes
                                    + " bytes instead.");
                        }

                        ESRIRecord record = makeESRIRecord(shapeType,
                                sRecord,
                                0);
                        v.addElement(record);
                    } catch (IOException ioe) {
                        Debug.error("SpatialIndex.locateRecords: IOException. ");
                        ioe.printStackTrace();
                        break;
                    }
                }
            }
        }

        if (Debug.debugging("spatialindex")) {
            Debug.output("Processed " + recNum + " records");
            Debug.output("Selected " + v.size() + " records");
        }
        int nRecords = v.size();

        ssx.close();
        shp.close();
        shp = null;
        ESRIRecord result[] = new ESRIRecord[nRecords];
        v.copyInto(result);
        return result;
View Full Code Here

        if (list == null) {
            list = new OMGraphicList();
        }

        if (shp == null) {
            shp = new BinaryBufferedFile(shpFileName);
        }

        if (shp == null) {
            return list;
        }
View Full Code Here

        if (retList == null) {
            retList = new OMGraphicList();
        }

        if (shp == null) {
            shp = new BinaryBufferedFile(shpFileName);
        }

        if (shp == null) {
            return retList;
        }
View Full Code Here

TOP

Related Classes of com.bbn.openmap.io.BinaryBufferedFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.