Package org.h2gis.functions.io.fgb.fileTable

## Class FGBDriver

- java.lang.Object
- - org.h2gis.functions.io.fgb.fileTable.FGBDriver

All Implemented Interfaces:
  `org.h2gis.api.FileDriver`

    public class FGBDriver
    extends Object
    implements org.h2gis.api.FileDriver

FlatGeobuffer reader driver

Author:
  Erwan Bocher, Nicolas Fortin

### Nested Class Summary

Nested Classes
`static class` `FGBDriver.FGBDriverCursor`

### Constructor Summary

Constructors
`FGBDriver()`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `cacheFeatureAddressFromIndex()` Using the Spatial index it is possible to quickly cache the file address of all features.
`void` `close()`
`int` `getEstimatedRowSize​(long rowId)`
`long` `getFeaturesOffset()`
`org.h2.value.Value` `getField​(long rowId, int columnId)`
`int` `getFieldCount()`
`static org.h2.value.Value[]` `getFieldsFromFileLocation​(FileChannel fileChannel, long featureAddress, long featuresOffset, org.wololo.flatgeobuf.HeaderMeta headerMeta, int geometryFieldIndex)`
`int` `getGeometryFieldIndex()`
`org.wololo.flatgeobuf.HeaderMeta` `getHeader()`
`long` `getRowCount()`
`void` `initDriverFromFile​(File fgbFile)` Init file header for DBF File
`void` `insertRow​(Object[] values)`
`boolean` `isCacheRowAddress()`
`org.h2.index.Cursor` `queryIndex​(org.locationtech.jts.geom.Envelope queryEnvelope)`
`void` `setCacheRowAddress​(boolean cacheRowAddress)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### FGBDriver

    public FGBDriver()

### Method Detail

#### initDriverFromFile

    public void initDriverFromFile​(File fgbFile)
                            throws IOException

Init file header for DBF File

Parameters:
  `fgbFile` - DBF File path
Throws:
  `IOException`

#### isCacheRowAddress

    public boolean isCacheRowAddress()

#### setCacheRowAddress

    public void setCacheRowAddress​(boolean cacheRowAddress)

Parameters:
  `cacheRowAddress` - If true the feature file address will be cached in order to reduce random access time. If the file will be read sequentially only you can disable the cache in order to reduce the memory footprint

#### getHeader

    public org.wololo.flatgeobuf.HeaderMeta getHeader()

#### getRowCount

    public long getRowCount()

Specified by:
  `getRowCount` in interface `org.h2gis.api.FileDriver`

#### getEstimatedRowSize

    public int getEstimatedRowSize​(long rowId)

Specified by:
  `getEstimatedRowSize` in interface `org.h2gis.api.FileDriver`

#### getFieldCount

    public int getFieldCount()

Specified by:
  `getFieldCount` in interface `org.h2gis.api.FileDriver`

#### close

    public void close()
               throws IOException

Specified by:
  `close` in interface `org.h2gis.api.FileDriver`
Throws:
  `IOException`

#### queryIndex

    public org.h2.index.Cursor queryIndex​(org.locationtech.jts.geom.Envelope queryEnvelope)
                                   throws IOException

Throws:
  `IOException`

#### cacheFeatureAddressFromIndex

    public void cacheFeatureAddressFromIndex()
                                      throws IOException

Using the Spatial index it is possible to quickly cache the file address of all features. Using this function before doing a random access should reduce the access time.

Throws:
  `IOException`

#### getFieldsFromFileLocation

    public static org.h2.value.Value[] getFieldsFromFileLocation​(FileChannel fileChannel,
                                                                 long featureAddress,
                                                                 long featuresOffset,
                                                                 org.wololo.flatgeobuf.HeaderMeta headerMeta,
                                                                 int geometryFieldIndex)
                                                          throws IOException

Parameters:
  `featureAddress` - Feature address in the file relative to the first feature
Returns:
Throws:
  `IOException`

#### getField

    public org.h2.value.Value getField​(long rowId,
                                       int columnId)
                                throws IOException

Specified by:
  `getField` in interface `org.h2gis.api.FileDriver`
Throws:
  `IOException`

#### getFeaturesOffset

    public long getFeaturesOffset()

#### insertRow

    public void insertRow​(Object[] values)
                   throws IOException

Specified by:
  `insertRow` in interface `org.h2gis.api.FileDriver`
Throws:
  `IOException`

#### getGeometryFieldIndex

    public int getGeometryFieldIndex()

Returns:
  Field index of the geometry when using the method getField