|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bbn.openmap.dataAccess.shape.ShapeUtils
com.bbn.openmap.layer.shape.ShapeFile
public class ShapeFile
Class representing an ESRI Shape File.
Usage: To verify a shape file: java com.bbn.openmap.layer.shape.ShapeFile -v shapeFile Append records from srcShapeFile to destShapeFile: java com.bbn.openmap.layer.shape.ShapeFile -a destShapeFile srcShapeFile Print information about the header and the number of records: java com.bbn.openmap.layer.shape.ShapeFile shapeFile
| Field Summary | |
|---|---|
static int |
DEFAULT_RECORD_BUFFER_SIZE
A default record size. |
protected ESRIBoundingBox |
fileBounds
Holds the bounds of the file (four doubles). |
protected long |
fileLength
Holds the length of the file, in bytes. |
protected int |
fileShapeType
Holds the shape type of the file. |
protected int |
fileVersion
Holds the version of the file, as an int. |
protected byte[] |
header
The buffer that holds the 100 byte header. |
protected java.io.RandomAccessFile |
raf
The read/write class for shape files. |
protected byte[] |
recBuf
A buffer for the current record's data. |
protected byte[] |
recHdr
A buffer for current record's header. |
static int |
SHAPE_FILE_CODE
A Shape File's magic number. |
static int |
SHAPE_FILE_VERSION
The currently handled version of Shape Files. |
| Constructor Summary | |
|---|---|
ShapeFile(java.io.File file)
Construct a ShapeFile from the given File. |
|
ShapeFile(java.lang.String name)
Construct a ShapeFile from a file name. |
|
| Method Summary | |
|---|---|
void |
add(ESRIRecord r)
Adds a record to the end of this file. |
void |
close()
Closes the shape file and disposes of resources. |
ESRIBoundingBox |
getBoundingBox()
Returns the bounding box of this shape file. |
long |
getFileLength()
Returns the length of the file in bytes. |
int |
getFileVersion()
Returns the version of the file. |
ESRIRecord |
getNextRecord()
Returns the next record from the shape file as an ESRIRecord. |
int |
getShapeType()
Returns the shape type of the file. |
protected void |
initHeader()
Reads or writes the header of a Shape file. |
static void |
main(java.lang.String[] args)
The driver for the command line interface. |
protected void |
readHeader()
Reads and parses the header of the file. |
void |
setShapeType(int newShapeType)
Sets the shape type of the file. |
void |
verify(boolean repair,
boolean verbose)
Verifies the contents of a shape file. |
protected void |
verifyRecordBuffer(int size)
Verifies that the record buffer is big enough to hold the given number of bytes. |
protected void |
writeHeader()
Writes a blank header into the shape file. |
| Methods inherited from class com.bbn.openmap.dataAccess.shape.ShapeUtils |
|---|
getStringForType, readBEInt, readBox, readLEDouble, readLEInt, readLEInt, readLELong, readPoint, writeBEInt, writeBox, writeLEDouble, writeLEInt, writeLELong, writePoint |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int SHAPE_FILE_CODE
public static final int SHAPE_FILE_VERSION
public static final int DEFAULT_RECORD_BUFFER_SIZE
protected java.io.RandomAccessFile raf
protected byte[] header
protected long fileLength
protected int fileVersion
protected int fileShapeType
protected ESRIBoundingBox fileBounds
protected byte[] recHdr
protected byte[] recBuf
| Constructor Detail |
|---|
public ShapeFile(java.lang.String name)
throws java.io.IOException
ShapeFile from a file name.
java.io.IOException - if something goes wrong opening or reading the
file.
public ShapeFile(java.io.File file)
throws java.io.IOException
ShapeFile from the given File.
file - A file object representing an ESRI Shape File
java.io.IOException - if something goes wrong opening or reading the
file.| Method Detail |
|---|
protected void initHeader()
throws java.io.IOException
After this function runs, the file pointer is set to byte 100, the first byte of the first record in the file.
java.io.IOException - if something goes wrong reading or writing the
shape file
protected void writeHeader()
throws java.io.IOException
java.io.IOException - if something goes wrong writing the shape file
protected void readHeader()
throws java.io.IOException
java.io.IOException - if something goes wrong reading the fileheader,
fileVersion,
fileLength,
fileShapeType,
fileBoundspublic long getFileLength()
public int getFileVersion()
public int getShapeType()
public void setShapeType(int newShapeType)
throws java.io.IOException,
java.lang.IllegalArgumentException
Shape types are enumerated in the class ShapeUtils.
newShapeType - the new shape type
java.io.IOException - if something goes wrong writing the file
java.lang.IllegalArgumentException - if file already has a shape typeShapeUtilspublic ESRIBoundingBox getBoundingBox()
public ESRIRecord getNextRecord()
throws java.io.IOException
ESRIRecord.
Each successive call gets the next record. There is no way to go back a
record. When there are no more records, null is returned.
java.io.IOException - if something goes wrong reading the file
public void add(ESRIRecord r)
throws java.io.IOException
r - the record to be added
java.io.IOException - if something goes wrong writing to the file
public void close()
throws java.io.IOException
java.io.IOException - if something goes wrong closing the file
public void verify(boolean repair,
boolean verbose)
throws java.io.IOException
repair - NOT CURRENTLY USED - would signal that the file should be
repaired if possibleverbose - NOT CURRENTLY USED - would cause the verifier to display
progress and status
java.io.IOException - if something goes wrong reading or writing the fileprotected void verifyRecordBuffer(int size)
size - the number of bytes the buffer needs to hold
public static void main(java.lang.String[] args)
throws java.io.IOException
See the file documentation for usage.
args - the command line arguments
java.io.IOException - if something goes wrong reading or writing the file
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||