Core Architecture
The GeoTools Core Architecture defines the foundational components and design principles that support the entire GeoTools library. This document explains the main architectural elements, their relationships, and the overall organization of the GeoTools codebase. For information about specific implementations, refer to the corresponding feature-specific pages.
Overall Architecture
GeoTools follows a modular architecture organized around key abstractions for geospatial data handling. The project is structured into several layers, with clear dependencies between components.
Core Modules
The GeoTools library is designed around a set of fundamental modules that provide the foundation for all functionality:
| Module | Purpose | Key Abstractions |
|---|---|---|
| gt-api | Core interfaces | DataStore, Feature, FeatureSource, Filter |
| gt-metadata | Base services and utilities | Citations, Logging, Factory system |
| gt-referencing | Coordinate reference systems | CRS, MathTransform, Position, Bounds |
| gt-main | Default implementations | DataStore implementations, Geometry utilities |
| gt-coverage | Raster data handling | GridCoverage2D, GridCoverageReader |
These modules form the backbone of GeoTools, with carefully managed dependencies to ensure that higher-level components can be used independently. The gt-api module (formerly gt-opengis) defines the core interfaces that are implemented throughout the library.
Data Model
GeoTools implements a comprehensive data model for handling both vector and raster geospatial data.
Spatial Data Abstractions
The spatial data model in GeoTools is built on a few key abstractions:
- Feature: The basic unit of vector data, typically representing a geographic entity with attributes and geometry
- GridCoverage2D: The basic unit of raster data, coupling a rendered image with spatial reference information
- Position: Represents a point in coordinate space (replaced DirectPosition in GeoTools 30.x)
- Bounds: Represents a bounding box in coordinate space (replaced Envelope in GeoTools 30.x)
- CoordinateReferenceSystem: Defines the spatial reference system for features and coverages
One of the most commonly used implementations is ReferencedEnvelope, which combines JTS Envelope with a coordinate reference system:
Data Access Framework
The GeoTools data access framework provides a consistent API for accessing both vector and raster data from various sources.
The framework is designed around the following core interfaces:
DataAccess/DataStore: For vector data access
- ContentDataStore: Base implementation for most file-based data stores
- JDBCDataStore: Base implementation for database-backed data stores
FeatureSource: Provides query capabilities against vector data
- FeatureCollection: Result of a query, provides iteration over Features
GridCoverageReader: For raster data access
- AbstractGridCoverageReader: Base implementation
- Format-specific implementations (GeoTIFF, ImageMosaic, etc.)
Module Dependencies
GeoTools modules have a carefully managed set of dependencies, designed to minimize coupling and prevent circular dependencies.
The dependency structure is designed to ensure that:
- The API module has minimal dependencies
- Implementation modules depend on the API but not vice versa
- Optional dependencies are clearly marked and isolated
- Higher-level modules (like gt-coverage) can depend on lower-level modules (like gt-main), but not vice versa
Factory System
GeoTools uses a factory system to instantiate implementations of key interfaces. This allows for:
- Separation of interface from implementation
- Pluggable implementations
- Hints-based customization of implementation selection
Common usage pattern:
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
Filter filter = ff.equals(ff.property("name"), ff.literal("value"));Notable Architectural Changes
In GeoTools 30.x, a significant architectural change occurred with the removal of the org.opengis package, moving interfaces to org.geotools.api. Key changes included:
- Renaming
gt-opengismodule togt-api - Moving interfaces from
org.opengis.*toorg.geotools.api.* - Merging
FilterFactory2intoFilterFactory - Replacing
DirectPositionwithPosition - Replacing
EnvelopewithBounds - Moving styling interfaces to
org.geotools.api.style
Extension Points
GeoTools is designed to be extended through several mechanisms:
- Plugins: Implement specific DataStore or GridCoverageReader interfaces
- Factories: Register custom implementations of core interfaces
- Extensions: Add specialized functionality building on core modules
Plugins are discovered through Java's ServiceLoader mechanism with service files located in META-INF/services/.
Conclusion
The GeoTools Core Architecture provides a flexible and extensible framework for geospatial data handling. It is characterized by:
- A modular design with clear separation of interfaces and implementations
- A factory system allowing for pluggable components
- Strong abstractions for both vector and raster data
- Flexible data access framework supporting various data formats
- Comprehensive coordinate reference system support
This architecture forms the foundation for all other GeoTools subsystems and extensions.