|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.fhg.igd.earth.model.input.shapefile.ShapeUtils de.fhg.igd.earth.model.input.shapefile.ShapeFile
Class representing an ESRI Shape File. Title : Earth Copyright : Copyright (c) 2001 Organisation : IGD FhG
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 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. |
Fields inherited from class de.fhg.igd.earth.model.input.shapefile.ShapeUtils |
SHAPE_FILE_HEADER_LENGTH, SHAPE_FILE_HEADER_LENGTH_DB, SHAPE_FILE_RECORD_HEADER_LENGTH, SHAPE_TYPE_ARC, SHAPE_TYPE_MULTIPOINT, SHAPE_TYPE_NULL, SHAPE_TYPE_POINT, SHAPE_TYPE_POLYGON, SHAPE_TYPE_POLYLINE |
Constructor Summary | |
ShapeFile(File file)
Construct a ShapeFile from the given
File . |
|
ShapeFile(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. |
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 de.fhg.igd.earth.model.input.shapefile.ShapeUtils |
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 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(String name) throws IOException
ShapeFile
from a file name.
IOException
- if something goes wrong opening or
reading the file.public ShapeFile(File file) throws IOException
ShapeFile
from the given
File
.
file
- A file object representing an ESRI Shape File
IOException
- if something goes wrong opening or
reading the file.Method Detail |
protected void initHeader() throws IOException
After this function runs, the file pointer is set to byte 100, the first byte of the first record in the file.
IOException
- if something goes wrong reading or writing
the shape fileprotected void writeHeader() throws IOException
IOException
- if something goes wrong writing the shape fileprotected void readHeader() throws IOException
IOException
- if something goes wrong reading the fileheader
,
fileVersion
,
fileLength
,
fileShapeType
,
fileBounds
public long getFileLength()
public int getFileVersion()
public int getShapeType()
public void setShapeType(int newShapeType) throws IOException, IllegalArgumentException
Shape types are enumerated in the class ShapeUtils.
newShapeType
- the new shape type
IOException
- if something goes wrong writing the file
IllegalArgumentException
- if file already has a shape typeShapeUtils
public ESRIBoundingBox getBoundingBox()
public ESRIRecord getNextRecord() throws 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.
IOException
- if something goes wrong reading the filepublic void add(ESRIRecord r) throws IOException
r
- the record to be added
IOException
- if something goes wrong writing to the filepublic void close() throws IOException
IOException
- if something goes wrong closing the filepublic void verify(boolean repair, boolean verbose) throws 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
IOException
- if something goes wrong reading or writing
the fileprotected void verifyRecordBuffer(int size)
size
- the number of bytes the buffer needs to hold
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |