public void writeHeaders ( ShapeType type ) throws IOException { try { handler = type . getShapeHandler ( ) ; } catch ( ShapefileException se ) { throw new IOException ( "Error with type " + type , se ) ; } if ( indexBuffer != null ) { indexBuffer . flush ( ) ; } if ( shapeBuffer != null ) { shapeBuffer . flush ( ) ; } long fileLength = shpChannel . position ( ) ; shpChannel . position ( 0 ) ; shxChannel . position ( 0 ) ; ShapefileHeader header = new ShapefileHeader ( ) ; Envelope writeBounds = bounds ; if ( writeBounds == null ) { writeBounds = new Envelope ( ) ; } indexBuffer = new WriteBufferManager ( shxChannel ) ; shapeBuffer = new WriteBufferManager ( shpChannel ) ; header . write ( shapeBuffer , type , cnt , ( int ) ( fileLength / 2 ) , writeBounds . getMinX ( ) , writeBounds . getMinY ( ) , writeBounds . getMaxX ( ) , writeBounds . getMaxY ( ) ) ; header . write ( indexBuffer , type , cnt , 50 + 4 * cnt , writeBounds . getMinX ( ) , writeBounds . getMinY ( ) , writeBounds . getMaxX ( ) , writeBounds . getMaxY ( ) ) ; offset = 50 ; this . type = type ; }
Write the headers for this shapefile . Use this function before inserting the first geometry then when all geometries are inserted .