Package org.arakhne.afc.io.shape
Class ShapeFileIndexReader
- java.lang.Object
-
- org.arakhne.afc.io.shape.AbstractCommonShapeFileReader<ShapeFileIndexRecord>
-
- org.arakhne.afc.io.shape.ShapeFileIndexReader
-
- All Implemented Interfaces:
AutoCloseable
,Iterable<ShapeFileIndexRecord>
public class ShapeFileIndexReader extends AbstractCommonShapeFileReader<ShapeFileIndexRecord>
This class is a shape file index reader.To have a lower memory foot-print, call
AbstractCommonShapeFileReader.disableSeek()
. Indeed, the seek feature forces this reader to maintain a buffer of all the file content.The specification of the ESRI Shape file format is described in the July 98 specification document.
- Since:
- 14.0
- Version:
- 17.0 2020-01-04 14:41:52
- Author:
- Stéphane GALLAND, Olivier LAMOTTE
- Maven Group Id:
- org.arakhne.afc.advanced
- Maven Artifact Id:
- shapefile
-
-
Field Summary
-
Fields inherited from class org.arakhne.afc.io.shape.AbstractCommonShapeFileReader
BLOCK_SIZE, expectedShapeType, fileSize, maxm, maxx, maxy, maxz, minm, minx, miny, minz
-
-
Constructor Summary
Constructors Constructor Description ShapeFileIndexReader(File file)
Constructor.ShapeFileIndexReader(InputStream inputStream)
Constructor.ShapeFileIndexReader(URL file)
Constructor.ShapeFileIndexReader(ReadableByteChannel channel)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getRecordCount()
Replies the count of records in the Shape file index.protected void
postHeaderReadingStage()
Called just after the header was read.protected ShapeFileIndexRecord
readRecord(int recordIndex)
Read a record according to its type.void
seek(int recordIndex)
Move the reading head at the specified record index.-
Methods inherited from class org.arakhne.afc.io.shape.AbstractCommonShapeFileReader
close, disableSeek, ensureAvailableBytes, getBoundsFromHeader, getFileReadingPosition, getFileSize, getShapeElementType, getTaskProgression, isHeaderRead, isSeekEnabled, iterator, iterator, iterator, iterator, postReadingStage, postRecordReadingStage, preReadingStage, read, readBEDouble, readBEInt, readHeader, readLEDouble, readLEInt, setReadingPosition, setTaskProgression, skipBytes
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
ShapeFileIndexReader
public ShapeFileIndexReader(ReadableByteChannel channel)
Constructor.- Parameters:
channel
- is the channel to read from.
-
ShapeFileIndexReader
public ShapeFileIndexReader(InputStream inputStream)
Constructor.- Parameters:
inputStream
- is the stream to read
-
ShapeFileIndexReader
public ShapeFileIndexReader(File file) throws IOException
Constructor.- Parameters:
file
- is the file to read- Throws:
IOException
- in case of error.
-
ShapeFileIndexReader
public ShapeFileIndexReader(URL file) throws IOException
Constructor.- Parameters:
file
- is the file to read- Throws:
IOException
- in case of error.
-
-
Method Detail
-
postHeaderReadingStage
protected void postHeaderReadingStage() throws IOException
Description copied from class:AbstractCommonShapeFileReader
Called just after the header was read.- Overrides:
postHeaderReadingStage
in classAbstractCommonShapeFileReader<ShapeFileIndexRecord>
- Throws:
IOException
- in case of error.
-
getRecordCount
public int getRecordCount()
Replies the count of records in the Shape file index.- Returns:
- the count of records in the Shape file index.
-
seek
public void seek(int recordIndex) throws IOException
Move the reading head at the specified record index.If the index is negative, the next record to read is assumed to be the first record. If the index is greater or equals to the count of records, the exception
EOFException
will be thrown.- Specified by:
seek
in classAbstractCommonShapeFileReader<ShapeFileIndexRecord>
- Parameters:
recordIndex
- is the index of record to reply at the next read.- Throws:
IOException
- in case of error.
-
readRecord
protected ShapeFileIndexRecord readRecord(int recordIndex) throws EOFException, IOException
Description copied from class:AbstractCommonShapeFileReader
Read a record according to its type.- Specified by:
readRecord
in classAbstractCommonShapeFileReader<ShapeFileIndexRecord>
- Parameters:
recordIndex
- is the index of the read record.- Returns:
- the element extracted from the record
- Throws:
EOFException
- if EOF is reach to early.IOException
- in case of error.
-
-