org.h2gis.drivers.shp.internal
Class ShapefileWriter

java.lang.Object
  extended by org.h2gis.drivers.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

Constructor Summary
ShapefileWriter(FileChannel shpChannel, FileChannel shxChannel)
          Creates a new instance of ShapeFileWriter
 
Method Summary
 void close()
          Close the underlying Channels.
 FileChannel getShpChannel()
           
 void writeGeometry(com.vividsolutions.jts.geom.Geometry g)
          Write a single Geometry to this shapefile.
 void writeHeaders(ShapeType type)
          Write the headers for this shapefile.Use this function before inserting the first geometry, then when all geometries are inserted.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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(com.vividsolutions.jts.geom.Geometry g)
                   throws IOException
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

public void close()
           throws IOException
Close the underlying Channels.

Throws:
IOException


Copyright © 2015 IRSTV CNRS-FR-2488. All Rights Reserved.