Class ShapefileReader
java.lang.Object
org.h2gis.functions.io.shp.internal.ShapefileReader
The general use of this class is:
FileChannel in = new FileInputStream("thefile.dbf").getChannel();
ShapefileReader r = new ShapefileReader( in ) while (r.hasNext()) { Geometry
shape = (Geometry) r.nextRecord().shape() // do stuff } r.close();
You don't have to immediately ask for the shape from the record. The
record will contain the bounds of the shape and will only read the shape when
the shape() method is called. This ShapefileReader.Record is the same object
every time, so if you need data from the Record, be sure to copy it.
- Author:
- jamesm, aaime, Ian Schneider
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Clean up any resources.org.locationtech.jts.geom.GeometrygeomAt(int offset) Fetch the next record information.Get the header.static ShapefileHeaderreadHeader(ReadableByteChannel channel) A short cut for reading the header from the given channel.voidsetHandler(ShapeHandler handler)
-
Constructor Details
-
ShapefileReader
Creates a new instance of ShapeFile.- Parameters:
channel- The ReadableByteChannel this reader will use.- Throws:
IOException- If problems arise.ShapefileException- If for some reason the file contains invalid records.
-
-
Method Details
-
readHeader
A short cut for reading the header from the given channel.- Parameters:
channel- The channel to read from.- Returns:
- A ShapefileHeader object.
- Throws:
IOException- If problems arise.
-
getHeader
Get the header. Its parsed in the constructor.- Returns:
- The header that is associated with this file.
-
close
Clean up any resources. Closes the channel.- Throws:
IOException- If errors occur while closing the channel.
-
geomAt
Fetch the next record information.- Parameters:
offset-- Returns:
- The record instance associated with this reader.
- Throws:
IOException
-
setHandler
- Parameters:
handler- The handler to set.
-