Module org.apache.sis.storage.sql

# Package org.apache.sis.storage.sql

package org.apache.sis.storage.sql
Data store capable to read and create features from a JDBC connection to a database. `SQLStore` takes a one or more tables at construction time. Each enumerated table is represented by a `FeatureType`. Each row in those table represents a `Feature` instance. Each relation defined by a foreigner key is represented by an `FeatureAssociationRole` to another feature (with transitive dependencies automatically resolved), and the other columns are represented by `AttributeType`.

The storage of spatial features in SQL databases is described by the OGC Simple feature access - Part 2: SQL option international standard, also known as ISO 19125-2. Implementation of geometric types and operations must be provided by the database (sometimes through an extension, for example PostGIS on PostgreSQL databases). This Java package uses those provided types and operations.

## Performance tips

A subset of features can be obtained by applying filters on the stream returned by `FeatureSet​.features(boolean)`. While the filter can be any `Predicate`, performances will be much better if they are instances of `Filter` because Apache SIS will know how to translate some of them to SQL statements.

In filter expressions like `ST_Intersects(A,B)` where the A and B parameters are two sub-expressions evaluating to geometry values, if one of those expressions is a literal, then that literal should be B. The reason is because the SQLMM standard requires us to project B in the Coordinate Reference System of A. If B is a literal, Apache SIS can do this transformation only once before to start the filtering process instead of every time that the filter needs to be evaluated.

## Limitations

- Current implementation does not scan the `"GEOMETRY_COLUMNS"` (from Simple Feature Access) or `"gpkg_content"` (from GeoPackage) tables for a default list of feature tables.
- Current implementation does not yet map geometric objects (e.g. PostGIS types).
- If a parent feature contains association to other features, those other features are created at the same time than the parent feature (no lazy instantiation yet).

Since:
  1.0

- Related Packages
  Module
  Package
  Description
  org.apache.sis.storage
  org.apache.sis.storage
  Data store base types for retrieving and saving geospatial data in various storage formats.
- Classes
  Class
  Description
  ResourceDefinition
  Definition of a resource (table, view or query) to include in a `SQLStore`.
  SQLStore
  A data store capable to read and create features from a spatial database.
  SQLStoreProvider
  Provider of `SQLStore` instances.