org.geotools.geopkg
Class GeoPackage

Object
  extended by GeoPackage

public class GeoPackage
extends Object

Provides access to a GeoPackage database.

Author:
Justin Deoliveira, OpenGeo

Nested Class Summary
static class GeoPackage.DataType
           
 
Field Summary
static String DATA_COLUMN_CONSTRAINTS
           
static String EXTENSIONS
           
static String GEOMETRY_COLUMNS
           
static String GEOPACKAGE_CONTENTS
           
static String METADATA
           
static String METADATA_REFERENCE
           
static String RASTER_COLUMNS
           
static String SPATIAL_REF_SYS
           
static String TILE_MATRIX_METADATA
           
static String TILE_MATRIX_SET
           
 
Constructor Summary
GeoPackage()
          Creates a new empty GeoPackage, generating a new file.
GeoPackage(File file)
          Creates a GeoPackage from an existing file.
GeoPackage(File file, String user, String passwd)
          Creates a GeoPackage from an existing file specifying database credentials.
 
Method Summary
 void add(FeatureEntry entry, SimpleFeatureCollection collection)
          Adds a new feature dataset to the geopackage.
 void add(FeatureEntry entry, SimpleFeatureSource source, Filter filter)
          Adds a new feature dataset to the geopackage.
 void add(RasterEntry entry, GridCoverage2D raster, AbstractGridFormat format)
          Adds a new raster dataset to the geopackage.
 void add(TileEntry entry, Tile tile)
          Adds a tile to the geopackage.
 void addCRS(CoordinateReferenceSystem crs, String auth, int srid)
          Adds a crs to the geopackage, registring it in the spatial_ref_sys table.
 void addCRS(int srid)
          Adds an epsg crs to the geopackage, registering it in the spatial_ref_sys table.
 void close()
          Closes the geopackage database connection.
 List<Entry> contents()
          Returns list of contents of the geopackage.
 void create(FeatureEntry entry, SimpleFeatureType schema)
          Creates a new feature entry in the geopackage.
 void create(TileEntry entry)
          Creates a new tile entry in the geopackage.
 FeatureEntry feature(String name)
          Looks up a feature entry by name.
 List<FeatureEntry> features()
          Lists all the feature entries in the geopackage.
 DataSource getDataSource()
          The database data source.
 File getFile()
          The underlying database file.
 int getTileBound(TileEntry entry, int zoom, boolean isMax, boolean isRow)
          Retrieve tile boundaries (min row, max row, min column and max column) for a particular zoom level, available in the actual data
 void init()
          Initializes the geopackage database.
 RasterEntry raster(String name)
          Looks up a raster entry by name.
 List<RasterEntry> rasters()
          Lists all the raster entries in the geopackage.
 SimpleFeatureReader reader(FeatureEntry entry, Filter filter, Transaction tx)
          Returns a reader for the contents of a feature dataset.
 GridCoverageReader reader(RasterEntry entry, AbstractGridFormat format)
          Returns a reader for the contents of a raster dataset.
 TileReader reader(TileEntry entry, Integer lowZoom, Integer highZoom, Integer lowCol, Integer highCol, Integer lowRow, Integer highRow)
          Retrieve tiles within certain zooms and column/row boundaries
 TileEntry tile(String name)
          Looks up a tile entry by name.
 List<TileEntry> tiles()
          Lists all the tile entries in the geopackage.
 SimpleFeatureWriter writer(FeatureEntry entry, boolean append, Filter filter, Transaction tx)
          Returns a writer used to modify or add to the contents of a feature dataset.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GEOPACKAGE_CONTENTS

public static final String GEOPACKAGE_CONTENTS
See Also:
Constant Field Values

GEOMETRY_COLUMNS

public static final String GEOMETRY_COLUMNS
See Also:
Constant Field Values

SPATIAL_REF_SYS

public static final String SPATIAL_REF_SYS
See Also:
Constant Field Values

RASTER_COLUMNS

public static final String RASTER_COLUMNS
See Also:
Constant Field Values

TILE_MATRIX_METADATA

public static final String TILE_MATRIX_METADATA
See Also:
Constant Field Values

METADATA

public static final String METADATA
See Also:
Constant Field Values

METADATA_REFERENCE

public static final String METADATA_REFERENCE
See Also:
Constant Field Values

TILE_MATRIX_SET

public static final String TILE_MATRIX_SET
See Also:
Constant Field Values

DATA_COLUMN_CONSTRAINTS

public static final String DATA_COLUMN_CONSTRAINTS
See Also:
Constant Field Values

EXTENSIONS

public static final String EXTENSIONS
See Also:
Constant Field Values
Constructor Detail

GeoPackage

public GeoPackage()
           throws IOException
Creates a new empty GeoPackage, generating a new file.

Throws:
IOException

GeoPackage

public GeoPackage(File file)
           throws IOException
Creates a GeoPackage from an existing file.

This constructor assumes no credentials are required to connect to the database.

Throws:
IOException

GeoPackage

public GeoPackage(File file,
                  String user,
                  String passwd)
           throws IOException
Creates a GeoPackage from an existing file specifying database credentials.

Throws:
IOException
Method Detail

getFile

public File getFile()
The underlying database file.

Note: this value may be null depending on how the geopackage was initialized.


getDataSource

public DataSource getDataSource()
The database data source.


init

public void init()
          throws IOException
Initializes the geopackage database.

This method creates all the necessary metadata tables.

Throws:
IOException

close

public void close()
Closes the geopackage database connection.

The application should always call this method when done with a geopackage to prevent connection leakage.


addCRS

public void addCRS(int srid)
            throws IOException
Adds an epsg crs to the geopackage, registering it in the spatial_ref_sys table.

This method will look up the srid in the local epsg database. Use #addCRS(CoordinateReferenceSystem, int) to specify an explicit CRS, authority, code entry.

Throws:
IOException

addCRS

public void addCRS(CoordinateReferenceSystem crs,
                   String auth,
                   int srid)
            throws IOException
Adds a crs to the geopackage, registring it in the spatial_ref_sys table.

Parameters:
crs - The crs to add.
auth - The authority code, example: epsg
srid - The spatial reference system id.
Throws:
IOException

contents

public List<Entry> contents()
Returns list of contents of the geopackage.


features

public List<FeatureEntry> features()
                            throws IOException
Lists all the feature entries in the geopackage.

Throws:
IOException

feature

public FeatureEntry feature(String name)
                     throws IOException
Looks up a feature entry by name.

Parameters:
name - THe name of the feature entry.
Returns:
The entry, or null if no such entry exists.
Throws:
IOException

create

public void create(FeatureEntry entry,
                   SimpleFeatureType schema)
            throws IOException
Creates a new feature entry in the geopackage.

The resulting feature dataset will be empty. The #writer(FeatureEntry, boolean, Transaction) method returns a writer object that can be used to populate the dataset.

Parameters:
entry - Contains metadata about the feature entry.
schema - The schema of the feature dataset.
Throws:
IOException - Any errors occurring while creating the new feature entry.

add

public void add(FeatureEntry entry,
                SimpleFeatureCollection collection)
         throws IOException
Adds a new feature dataset to the geopackage.

Parameters:
entry - Contains metadata about the feature entry.
collection - The simple feature collection to add to the geopackage.
Throws:
IOException - Any errors occurring while adding the new feature dataset.

add

public void add(FeatureEntry entry,
                SimpleFeatureSource source,
                Filter filter)
         throws IOException
Adds a new feature dataset to the geopackage.

Parameters:
entry - Contains metadata about the feature entry.
source - The dataset to add to the geopackage.
filter - Filter specifying what subset of feature dataset to include, may be null to specify no filter.
Throws:
IOException - Any errors occurring while adding the new feature dataset.

writer

public SimpleFeatureWriter writer(FeatureEntry entry,
                                  boolean append,
                                  Filter filter,
                                  Transaction tx)
                           throws IOException
Returns a writer used to modify or add to the contents of a feature dataset.

Parameters:
entry - The feature entry.
append - Flag controlling whether to modify existing contents, or append to the dataset.
filter - Filter determining what subset of dataset to modify, only relevant when append set to false. May be null to specify no filter.
tx - Transaction object, may be null to specify auto commit transaction.
Throws:
IOException

reader

public SimpleFeatureReader reader(FeatureEntry entry,
                                  Filter filter,
                                  Transaction tx)
                           throws IOException
Returns a reader for the contents of a feature dataset.

Parameters:
entry - The feature entry.
filter - Filter Filter determining what subset of dataset to return. May be null to specify no filter.
tx - Transaction object, may be null to specify auto commit transaction.
Throws:
IOException

rasters

public List<RasterEntry> rasters()
                          throws IOException
Lists all the raster entries in the geopackage.

Throws:
IOException

raster

public RasterEntry raster(String name)
                   throws IOException
Looks up a raster entry by name.

Parameters:
name - THe name of the raster entry.
Returns:
The entry, or null if no such entry exists.
Throws:
IOException

add

public void add(RasterEntry entry,
                GridCoverage2D raster,
                AbstractGridFormat format)
         throws IOException
Adds a new raster dataset to the geopackage.

Parameters:
entry - Contains metadata about the raster entry.
raster - The raster dataset.
format - The format in which to store the raster in the database.
Throws:
IOException - Any errors occurring while adding the new feature dataset.

reader

public GridCoverageReader reader(RasterEntry entry,
                                 AbstractGridFormat format)
                          throws IOException
Returns a reader for the contents of a raster dataset.

Parameters:
entry - The raster entry.
format - Format of the raster dataset.
Throws:
IOException

tiles

public List<TileEntry> tiles()
                      throws IOException
Lists all the tile entries in the geopackage.

Throws:
IOException

tile

public TileEntry tile(String name)
               throws IOException
Looks up a tile entry by name.

Parameters:
name - THe name of the tile entry.
Returns:
The entry, or null if no such entry exists.
Throws:
IOException

create

public void create(TileEntry entry)
            throws IOException
Creates a new tile entry in the geopackage.

Parameters:
entry - The tile entry.
Throws:
IOException

add

public void add(TileEntry entry,
                Tile tile)
         throws IOException
Adds a tile to the geopackage.

Parameters:
entry - The tile metadata entry.
tile - The tile.
Throws:
IOException

reader

public TileReader reader(TileEntry entry,
                         Integer lowZoom,
                         Integer highZoom,
                         Integer lowCol,
                         Integer highCol,
                         Integer lowRow,
                         Integer highRow)
                  throws IOException
Retrieve tiles within certain zooms and column/row boundaries

Parameters:
entry - the tile entry
lowZoom - low zoom boundary
highZoom - high zoom boundary
lowCol - low column boundary
highCol - high column boundary
lowRow - low row boundary
highRow - high row boundary
Returns:
Throws:
IOException

getTileBound

public int getTileBound(TileEntry entry,
                        int zoom,
                        boolean isMax,
                        boolean isRow)
                 throws IOException
Retrieve tile boundaries (min row, max row, min column and max column) for a particular zoom level, available in the actual data

Parameters:
entry - The tile entry
zoom - the zoom level
isMax - true for max boundary, false for min boundary
isRow - true for rows, false for columns
Returns:
the min/max column/row of the zoom level available in the data
Throws:
IOException


Copyright © 1996-2014 Geotools. All Rights Reserved.