public class ShapefileReader extends Object
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.| Constructor and Description |
|---|
ShapefileReader(FileChannel channel)
Creates a new instance of ShapeFile.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Clean up any resources.
|
org.locationtech.jts.geom.Geometry |
geomAt(int offset)
Fetch the next record information.
|
ShapefileHeader |
getHeader()
Get the header.
|
static ShapefileHeader |
readHeader(ReadableByteChannel channel)
A short cut for reading the header from the given channel.
|
void |
setHandler(ShapeHandler handler) |
public ShapefileReader(FileChannel channel) throws IOException, ShapefileException
channel - The ReadableByteChannel this reader will use.IOException - If problems arise.ShapefileException - If for some reason the file contains invalid records.public static ShapefileHeader readHeader(ReadableByteChannel channel) throws IOException
channel - The channel to read from.IOException - If problems arise.public ShapefileHeader getHeader()
public void close()
throws IOException
IOException - If errors occur while closing the channel.public org.locationtech.jts.geom.Geometry geomAt(int offset)
throws IOException
offset - IOExceptionpublic void setHandler(ShapeHandler handler)
handler - The handler to set.Copyright © 2019 CNRS. All rights reserved.