org.deegree_impl.io.shpapi
Class IndexFile

java.lang.Object
  extended byorg.deegree_impl.io.shpapi.IndexFile

public class IndexFile
extends java.lang.Object

Class representing an ESRI Shape File.

Uses class ShapeUtils modified from the original package com.bbn.openmap.layer.shape
Copyright (C) 1998 BBN Corporation 10 Moulton St. Cambridge, MA 02138

Last changes:
17.12.1999 ap: import clauses added
31.07.2000 ap: method writeIndexFileHeader(SHPEnvelope mbr) added
31.07.2000 ap: method appendRecord(IndexRecord record, SHPEnvelope mbr) added

-------------------------------------------------------------------------

Version:
31.07.2000
Author:
Andreas Poth


Field Summary
private  java.lang.String _shx
           
private  int filelength
          length of the indexfile
private  SHPEnvelope fileMBR
          minimum bounding rectangle of the shape-file
private  FileHeader ifh
          IndexFileHeader is equal to ShapeFileHeader
private static int INDEX_RECORD_LENGTH
          The length of an index record. (8 byte)
private  IndexRecord[] indexArray
          array which holds the content of .shx-file:
private  long offset
          file position offset
private  java.io.RandomAccessFile rafShx
           
private  int RecordNum
          number of Records in .shp, .shx., .dbf has to be identical
 
Constructor Summary
IndexFile(java.lang.String url)
          Construct a IndexFile from a file name.
IndexFile(java.lang.String url, java.lang.String rwflag)
          Construct a IndexFile from a file name.
 
Method Summary
 void appendRecord(IndexRecord record, SHPEnvelope mbr)
          appends an index record to the indexfile
 void close()
           
 SHPEnvelope getFileMBR()
          method: getFileMBR()
returns the minimum bounding rectangle of the shape-file
 IndexRecord[] getIndexArray()
          method: getIndexArray()
clones local field indexArray
 IndexRecord getIndexRecord(int RecNo)
          method: getIndexRecord (int RecNo)
function to get Index Record by Record number
 int getRecordLength(int RecNo)
          method: getRecordLength (int RecNo)
function to get Record Length by Record number
 int getRecordNum()
          method: getRecordNum()
function to get number of Records
 int getRecordOffset(int RecNo)
          methode: getRecordOffset (int RecNo)
function to get Record offset by Record number
private  void setIndexArray()
          method: setIndexArray()
local constructor for local field indexArray
 void writeHeader(int shptype, SHPEnvelope mbr)
          method: writeHeader(int filelength, byte shptype,SHPEnvelope mbr)
Writes a header into the index file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_shx

private final java.lang.String _shx
See Also:
Constant Field Values

rafShx

private java.io.RandomAccessFile rafShx

INDEX_RECORD_LENGTH

private static final int INDEX_RECORD_LENGTH
The length of an index record. (8 byte)

See Also:
Constant Field Values

indexArray

private IndexRecord[] indexArray
array which holds the content of .shx-file:


ifh

private FileHeader ifh
IndexFileHeader is equal to ShapeFileHeader


fileMBR

private SHPEnvelope fileMBR
minimum bounding rectangle of the shape-file


RecordNum

private int RecordNum
number of Records in .shp, .shx., .dbf has to be identical


offset

private long offset
file position offset


filelength

private int filelength
length of the indexfile

Constructor Detail

IndexFile

public IndexFile(java.lang.String url)
          throws java.io.IOException
Construct a IndexFile from a file name.


IndexFile

public IndexFile(java.lang.String url,
                 java.lang.String rwflag)
          throws java.io.IOException
Construct a IndexFile from a file name.

Method Detail

close

public void close()

writeHeader

public void writeHeader(int shptype,
                        SHPEnvelope mbr)
                 throws java.io.IOException
method: writeHeader(int filelength, byte shptype,SHPEnvelope mbr)
Writes a header into the index file.

Throws:
java.io.IOException

getFileMBR

public SHPEnvelope getFileMBR()
method: getFileMBR()
returns the minimum bounding rectangle of the shape-file


setIndexArray

private void setIndexArray()
                    throws java.io.IOException
method: setIndexArray()
local constructor for local field indexArray

Throws:
java.io.IOException

getIndexArray

public IndexRecord[] getIndexArray()
method: getIndexArray()
clones local field indexArray


getRecordNum

public int getRecordNum()
method: getRecordNum()
function to get number of Records


getRecordOffset

public int getRecordOffset(int RecNo)
methode: getRecordOffset (int RecNo)
function to get Record offset by Record number


getRecordLength

public int getRecordLength(int RecNo)
method: getRecordLength (int RecNo)
function to get Record Length by Record number


getIndexRecord

public IndexRecord getIndexRecord(int RecNo)
method: getIndexRecord (int RecNo)
function to get Index Record by Record number


appendRecord

public void appendRecord(IndexRecord record,
                         SHPEnvelope mbr)
                  throws java.io.IOException
appends an index record to the indexfile

Throws:
java.io.IOException