org.h2gis.drivers.shp.internal
Class SHPDriver

java.lang.Object
  extended by org.h2gis.drivers.shp.internal.SHPDriver
All Implemented Interfaces:
FileDriver

public class SHPDriver
extends Object
implements FileDriver

Merge ShapeFileReader and DBFReader. TODO Handle SHP without SHX and/or DBF How to use: In Write mode, Declare fields by calling initDriver(java.io.File, ShapeType, org.h2gis.drivers.dbf.internal.DbaseFileHeader) then write row using

Author:
Nicolas Fortin

Field Summary
 File prjFile
           
 
Constructor Summary
SHPDriver()
           
 
Method Summary
 void close()
          Close the file, free resources.
 DbaseFileHeader getDbaseFileHeader()
           
 int getFieldCount()
           
 int getGeometryFieldIndex()
           
 Object[] getRow(long rowId)
           
 long getRowCount()
           
 ShapefileHeader getShapeFileHeader()
           
 int getSrid()
          Get the SRID code
 void initDriver(File shpFile, ShapeType shapeType, DbaseFileHeader dbaseHeader)
          Init Driver for Write mode
 void initDriverFromFile(File shpFile)
          Init this driver from existing files, then open theses files.
 void initDriverFromFile(File shpFile, String forceEncoding)
          Init this driver from existing files, then open theses files.
 void insertRow(Object[] values)
          Insert values in the row
 void setGeometryFieldIndex(int geometryFieldIndex)
           
 void setSRID(int srid)
          Set a SRID code that will be used for geometries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

prjFile

public File prjFile
Constructor Detail

SHPDriver

public SHPDriver()
Method Detail

setGeometryFieldIndex

public void setGeometryFieldIndex(int geometryFieldIndex)
Parameters:
geometryFieldIndex - The geometry field index in getRow() array.

insertRow

public void insertRow(Object[] values)
               throws IOException
Insert values in the row

Specified by:
insertRow in interface FileDriver
Parameters:
values -
Throws:
IOException

getGeometryFieldIndex

public int getGeometryFieldIndex()
Returns:
The geometry field index in getRow() array.

initDriver

public void initDriver(File shpFile,
                       ShapeType shapeType,
                       DbaseFileHeader dbaseHeader)
                throws IOException
Init Driver for Write mode

Parameters:
shpFile -
shapeType -
dbaseHeader -
Throws:
IOException

initDriverFromFile

public void initDriverFromFile(File shpFile)
                        throws IOException
Init this driver from existing files, then open theses files.

Parameters:
shpFile - Shape file path.
Throws:
IOException

initDriverFromFile

public void initDriverFromFile(File shpFile,
                               String forceEncoding)
                        throws IOException
Init this driver from existing files, then open theses files.

Parameters:
shpFile - Shape file path.
forceEncoding - If defined use this encoding instead of the one defined in dbf header.
Throws:
IOException

getDbaseFileHeader

public DbaseFileHeader getDbaseFileHeader()
Returns:
Dbase file header

getRowCount

public long getRowCount()
Specified by:
getRowCount in interface FileDriver
Returns:
Row count

getShapeFileHeader

public ShapefileHeader getShapeFileHeader()
Returns:
ShapeFile header

close

public void close()
           throws IOException
Description copied from interface: FileDriver
Close the file, free resources.

Specified by:
close in interface FileDriver
Throws:
IOException

getFieldCount

public int getFieldCount()

getRow

public Object[] getRow(long rowId)
                throws IOException
Specified by:
getRow in interface FileDriver
Parameters:
rowId - Row index [0-getRowCount()[
Returns:
The row content
Throws:
IOException - Read error

setSRID

public void setSRID(int srid)
Set a SRID code that will be used for geometries.

Parameters:
srid -

getSrid

public int getSrid()
Get the SRID code

Returns:


Copyright © 2015 CNRS. All Rights Reserved.