Package org.geotools.vectortiles.store
Overview
This package provides reusable abstractions for creating GeoTools DataStores that read vector tiles from tile
archives or services. While designed primarily for PMTiles, these abstractions can be used with any tiled vector data
source that implements the Tileverse VectorTileStore
interface.
Architecture
The package follows a layered architecture that separates GeoTools integration concerns from tile-specific logic:
┌─────────────────────────────────────────────┐ │ GeoTools Query API (Query, Filter, etc.) │ └─────────────────┬───────────────────────────┘ │ ┌─────────────────▼───────────────────────────┐ │ VectorTilesFeatureSource │ │ - Query translation │ │ - Zoom level selection │ │ - Spatial filtering optimization │ │ - CRS transformation │ └─────────────────┬───────────────────────────┘ │ ┌─────────────────▼───────────────────────────┐ │ VectorTilesFeatureReader │ │ - Vector tile → GeoTools feature mapping │ │ - Clip mask handling │ │ - Feature filtering │ └─────────────────┬───────────────────────────┘ │ ┌─────────────────▼───────────────────────────┐ │ Tileverse VectorTileStore │ │ - Tile reading │ │ - Spatial indexing │ │ - MVT decoding │ └─────────────────────────────────────────────┘
Core Classes
Data Store Layer
VectorTilesDataStore
- Abstract base DataStore for vector tiles
Feature Access Layer
VectorTilesFeatureSource
- Feature source with query optimizationVectorTilesFeatureReader
- Converts vector tile features to GeoTools featuresVectorTilesSimpleFeature
- SimpleFeature wrapper for vector tile features
Utility Classes
StreamFeatureReader
- Stream-based feature reader with filtering and paginationExtractMultiBoundsFilterVisitor
- Extracts bounding boxes from complex filters as a list of individual envelopes from spatial predicates, forVectorTileStore
to skip tiles that would otherwise be included only as the result of union'ing all the bounding boxes in the GeoTools filter.VectorTilesFeaturePropertyAccessorFactory
- Property access for filtering at thevector tile
level
Main Features
Query Optimization
- Automatic Zoom Level Selection: Selects the optimal zoom level based on query resolution hints
(
Hints.GEOMETRY_DISTANCE
,GEOMETRY_SIMPLIFICATION
,GEOMETRY_GENERALIZATION
) - Spatial Filtering: Extracts bounding boxes from filters to minimize tile reads
- Pre-Filtering: Applies filters at the vector tile level before converting to GeoTools features
- Property Selection: Supports schema subsetting to reduce data transfer
CRS Transformation
- Efficient Reprojection: Uses affine transformations for in-place coordinate sequence transformation where possible
- Filter Reprojection: Automatically reprojects spatial filters to the native CRS
Rendering Support
- Clip Masks: Provides tile boundary clip masks via
Hints.GEOMETRY_CLIP
for correct rendering - Generalization Hints: Supports topology-preserving and non-topology-preserving simplification
Query Capabilities
The vector tiles feature source supports:
- Filtering: Full GeoTools filter support (spatial, attribute, logical)
- Reprojection: Automatic CRS transformation
- Retyping: Property selection and schema subsetting
- Pagination: Offset and limit support
- Sorting: Natural order only (tile order)
Feature Type Schema
Feature types are automatically derived from vector layer metadata (TileJSON):
- Attribute Fields: Mapped from TileJSON field definitions (String, Number, Boolean)
- Geometry Attribute: Added automatically with the tile matrix set's CRS
- Type Name: Derived from the layer ID
- Description: Optional layer description from metadata
Zoom Level Selection Strategy
The zoom level selection algorithm considers:
- Query resolution hints (GEOMETRY_DISTANCE, etc.)
- Layer-specific min/max zoom levels from TileJSON
- Tile matrix set available zoom levels
- Query strategy:
- SPEED: When simplification hints are present, favors lower zoom levels
- QUALITY: When no simplification hints, favors higher zoom levels
Implementation Guide
To create a new vector tile datastore:
// 1. Implement VectorTileStore for your tile source
public class MyVectorTileStore implements VectorTileStore {
// Implement tile reading, metadata, etc.
}
// 2. Extend VectorTilesDataStore
public class MyDataStore extends VectorTilesDataStore {
public MyDataStore(VectorTileStore tileStore) throws IOException {
super(MyDataStoreFactory.INSTANCE, tileStore);
}
}
// 3. Create a DataStoreFactory
public class MyDataStoreFactory implements DataStoreFactorySpi {
public MyDataStore createDataStore(Map<String, ?> params) {
// Create VectorTileStore and wrap it
}
}
Thread Safety
All classes in this package are designed for thread-safe concurrent access. The underlying
VectorTileStore
must also be thread-safe.
Performance Considerations
- Feature Count: Returns -1 (expensive to calculate for tiled data)
- Bounds Calculation: Returns null for filtered queries (requires full scan)
- Memory Usage: Features are streamed, not loaded entirely into memory
- Filter Pushdown: Spatial and attribute filters are applied at the vector tile level before feature conversion
Related Packages
org.geotools.pmtiles.store
- Concrete PMTiles DataStore implementation
- See Also:
-
ClassesClassDescriptionLike
DirectPropertyAccessorFactory
but works onSimpleFeature
attribtues, notProperty
, so we can handle attribute names like @name from vector tilesAbstract base GeoTools DataStore implementation for tiled vector data sources.PropertyAccessorFactory
that can access properties ofVectorTile.Layer.Feature
sofilters
can be evaluated against them before converting toSimpleFeature
.Feature source for a single vector layer in a tiled vector dataset.