Class ShapefileWriter
- java.lang.Object
-
- org.h2gis.functions.io.shp.internal.ShapefileWriter
-
public class ShapefileWriter extends Object
ShapefileWriter allows for the storage of geometries in esris shp format. During writing, an index will also be created. To create a ShapefileWriter, do something like
GeometryCollection geoms; File shp = new File("myshape.shp"); File shx = new File("myshape.shx"); ShapefileWriter writer = new ShapefileWriter( shp.getChannel(),shx.getChannel() ); writer.write(geoms,ShapeType.ARC);This example assumes that each shape in the collection is a LineString.- Author:
- jamesm, aaime, Ian Schneider
- See Also:
- ShapefileWriter.java
-
-
Constructor Summary
Constructors Constructor Description ShapefileWriter(FileChannel shpChannel, FileChannel shxChannel)Creates a new instance of ShapeFileWriter
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the underlying Channels.FileChannelgetShpChannel()voidwriteGeometry(org.locationtech.jts.geom.Geometry g)Write a single Geometry to this shapefile.voidwriteHeaders(ShapeType type)Write the headers for this shapefile.Use this function before inserting the first geometry, then when all geometries are inserted.
-
-
-
Constructor Detail
-
ShapefileWriter
public ShapefileWriter(FileChannel shpChannel, FileChannel shxChannel) throws IOException
Creates a new instance of ShapeFileWriter- Parameters:
shpChannel-shxChannel-- Throws:
IOException
-
-
Method Detail
-
getShpChannel
public FileChannel getShpChannel()
- Returns:
- The Shape File Channel
-
writeHeaders
public void writeHeaders(ShapeType type) throws IOException
Write the headers for this shapefile.Use this function before inserting the first geometry, then when all geometries are inserted.- Parameters:
type- Shape type- Throws:
IOException
-
writeGeometry
public void writeGeometry(org.locationtech.jts.geom.Geometry g) throws IOExceptionWrite a single Geometry to this shapefile. The Geometry must be compatable with the ShapeType assigned during the writing of the headers.- Parameters:
g-- Throws:
IOException
-
close
public void close() throws IOExceptionClose the underlying Channels.- Throws:
IOException
-
-