public class GeoPackage extends Object
Modifier and Type | Class and Description |
---|---|
static class |
GeoPackage.DataType |
Modifier and Type | Field and Description |
---|---|
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_INDEX |
static String |
SPATIAL_REF_SYS |
static String |
TILE_MATRIX_METADATA |
static String |
TILE_MATRIX_SET |
protected GeoPkgGeomWriter.Configuration |
writerConfig |
Constructor and Description |
---|
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.
|
GeoPackage(File file,
String user,
String passwd,
boolean readOnly)
Creates a GeoPackage from an existing file specifying database credentials.
|
Modifier and Type | Method and Description |
---|---|
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(TileEntry entry,
Tile tile)
Adds a tile to the geopackage.
|
static void |
addCRS(Connection cx,
int srid,
String srsName,
String organization,
int organizationCoordSysId,
String definition,
String description) |
void |
addCRS(CoordinateReferenceSystem crs,
String auth,
int srid)
Adds a crs to the geopackage, registering 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.
|
protected static void |
addDefaultSpatialReferences(Connection cx) |
void |
addRange(String attribute,
Integer low,
Integer high,
List<String> q) |
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.
|
void |
createSpatialIndex(FeatureEntry e)
Create a spatial index
|
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.
|
protected String |
getSpatialIndexName(FeatureEntry entry) |
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
|
GeoPkgGeomWriter.Configuration |
getWriterConfiguration() |
boolean |
hasSpatialIndex(FeatureEntry entry)
Verifies if a spatial index is present
|
void |
init()
Initializes the geopackage database.
|
SimpleFeatureReader |
reader(FeatureEntry entry,
Filter filter,
Transaction tx)
Returns a reader for the contents of a feature 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.
|
Set<Identifier> |
searchSpatialIndex(FeatureEntry entry,
Double minX,
Double minY,
Double maxX,
Double maxY)
Searches a spatial index.
|
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.
|
public static final String GEOPACKAGE_CONTENTS
public static final String GEOMETRY_COLUMNS
public static final String SPATIAL_REF_SYS
public static final String RASTER_COLUMNS
public static final String TILE_MATRIX_METADATA
public static final String METADATA
public static final String METADATA_REFERENCE
public static final String TILE_MATRIX_SET
public static final String DATA_COLUMN_CONSTRAINTS
public static final String EXTENSIONS
public static final String SPATIAL_INDEX
protected GeoPkgGeomWriter.Configuration writerConfig
public GeoPackage() throws IOException
IOException
public GeoPackage(File file) throws IOException
This constructor assumes no credentials are required to connect to the database.
IOException
public GeoPackage(File file, String user, String passwd) throws IOException
IOException
public GeoPackage(File file, String user, String passwd, boolean readOnly) throws IOException
IOException
public GeoPkgGeomWriter.Configuration getWriterConfiguration()
public File getFile()
Note: this value may be null
depending on how the geopackage was initialized.
public DataSource getDataSource()
public void init() throws IOException
This method creates all the necessary metadata tables.
IOException
public void close()
The application should always call this method when done with a geopackage to prevent connection leakage.
public void addCRS(int srid) throws IOException
This method will look up the srid in the local epsg database. Use #addCRS(CoordinateReferenceSystem, int)
to specify an explicit CRS, authority, code entry.
IOException
protected static void addDefaultSpatialReferences(Connection cx) throws SQLException
SQLException
public static void addCRS(Connection cx, int srid, String srsName, String organization, int organizationCoordSysId, String definition, String description) throws IOException
IOException
public void addCRS(CoordinateReferenceSystem crs, String auth, int srid) throws IOException
crs
- The crs to add.auth
- The authority code, example: epsgsrid
- The spatial reference system id.IOException
public List<FeatureEntry> features() throws IOException
IOException
public FeatureEntry feature(String name) throws IOException
name
- THe name of the feature entry.null
if no such entry exists.IOException
public void create(FeatureEntry entry, SimpleFeatureType schema) throws IOException
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.
entry
- Contains metadata about the feature entry.schema
- The schema of the feature dataset.IOException
- Any errors occurring while creating the new feature entry.public void add(FeatureEntry entry, SimpleFeatureCollection collection) throws IOException
entry
- Contains metadata about the feature entry.collection
- The simple feature collection to add to the geopackage.IOException
- Any errors occurring while adding the new feature dataset.public void add(FeatureEntry entry, SimpleFeatureSource source, Filter filter) throws IOException
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.IOException
- Any errors occurring while adding the new feature dataset.public SimpleFeatureWriter writer(FeatureEntry entry, boolean append, Filter filter, Transaction tx) throws IOException
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.IOException
public SimpleFeatureReader reader(FeatureEntry entry, Filter filter, Transaction tx) throws IOException
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.IOException
public void createSpatialIndex(FeatureEntry e) throws IOException
e
- feature entry to create spatial index forIOException
public List<TileEntry> tiles() throws IOException
IOException
public TileEntry tile(String name) throws IOException
name
- THe name of the tile entry.null
if no such entry exists.IOException
public void create(TileEntry entry) throws IOException
entry
- The tile entry.IOException
public void add(TileEntry entry, Tile tile) throws IOException
entry
- The tile metadata entry.tile
- The tile.IOException
public TileReader reader(TileEntry entry, Integer lowZoom, Integer highZoom, Integer lowCol, Integer highCol, Integer lowRow, Integer highRow) throws IOException
entry
- the tile entrylowZoom
- low zoom boundaryhighZoom
- high zoom boundarylowCol
- low column boundaryhighCol
- high column boundarylowRow
- low row boundaryhighRow
- high row boundaryIOException
protected String getSpatialIndexName(FeatureEntry entry)
public boolean hasSpatialIndex(FeatureEntry entry) throws IOException
entry
- The feature entry.IOException
public Set<Identifier> searchSpatialIndex(FeatureEntry entry, Double minX, Double minY, Double maxX, Double maxY) throws IOException
entry
- The feature entry.minX
- Optional minimum x boundary.minY
- Optional minimum y boundary.maxX
- Optional maximum x boundary.maxY
- Optional maximum y boundary.IOException
public int getTileBound(TileEntry entry, int zoom, boolean isMax, boolean isRow) throws IOException
entry
- The tile entryzoom
- the zoom levelisMax
- true for max boundary, false for min boundaryisRow
- true for rows, false for columnsIOException
Copyright © 1996–2019 Geotools. All rights reserved.