Class SHPDriver

java.lang.Object
org.h2gis.functions.io.shp.internal.SHPDriver
All Implemented Interfaces:
org.h2gis.api.FileDriver

public class SHPDriver extends Object implements org.h2gis.api.FileDriver
Merge ShapeFileReader and DBFReader. TODO Handle SHP without SHX and/or DBF How to use: In Write mode, Declare fields by calling initDriver(File, ShapeType, DbaseFileHeader) Driver(java.io.File, ShapeType, org.h2gis.drivers.dbf.internal.DbaseFileHeader)} then write row using
Author:
Nicolas Fortin
  • Field Details

    • shpFile

      public File shpFile
    • shxFile

      public File shxFile
    • dbfFile

      public File dbfFile
    • prjFile

      public File prjFile
  • Constructor Details

    • SHPDriver

      public SHPDriver()
  • Method Details

    • 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 org.h2gis.api.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 org.h2gis.api.FileDriver
    • getShapeFileHeader

      public ShapefileHeader getShapeFileHeader()
      Returns:
      ShapeFile header
    • close

      public void close() throws IOException
      Specified by:
      close in interface org.h2gis.api.FileDriver
      Throws:
      IOException
    • getFieldCount

      public int getFieldCount()
      Specified by:
      getFieldCount in interface org.h2gis.api.FileDriver
    • getEstimatedRowSize

      public int getEstimatedRowSize(long rowId)
      Specified by:
      getEstimatedRowSize in interface org.h2gis.api.FileDriver
    • getField

      public org.h2.value.Value getField(long rowId, int column) throws IOException
      Specified by:
      getField in interface org.h2gis.api.FileDriver
      Throws:
      IOException
    • 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: