Class ShapefileWriter
java.lang.Object
org.h2gis.functions.io.shp.internal.ShapefileWriter
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
-
Constructor Summary
ConstructorsConstructorDescriptionShapefileWriter(FileChannel shpChannel, FileChannel shxChannel) Creates a new instance of ShapeFileWriter -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the underlying Channels.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 Details
-
ShapefileWriter
Creates a new instance of ShapeFileWriter- Parameters:
shpChannel-shxChannel-- Throws:
IOException
-
-
Method Details
-
getShpChannel
- Returns:
- The Shape File Channel
-
writeHeaders
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
Write 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
Close the underlying Channels.- Throws:
IOException
-