Vector Data Processing
Overview
This page documents the vector data processing capabilities in GeoTools, focusing on how geospatial vector data is accessed, queried, manipulated, and transformed. Vector data in GeoTools represents discrete geographic features with geometry (points, lines, polygons) and attributes, primarily stored in databases and other data sources.
The vector processing subsystem provides:
- Database-independent APIs with optimized implementations for specific databases
- Filter-based querying with translation to SQL
- Feature transformation and manipulation capabilities
- Support for complex feature types and feature chaining
- Integration with other GeoTools subsystems
For raster data processing capabilities, see Raster Data Processing.
Vector Data Store Architecture
Vector data in GeoTools is accessed through data stores, with JDBC-based data stores being the primary implementation for working with database-stored vector data.
JDBCDataStore Core Components
The JDBCDataStore serves as the main entry point for vector data access and has several key components:
| Component | Purpose |
|---|---|
SQLDialect | Handles database-specific operations and SQL generation |
JDBCFeatureSource | Provides read access to vector features |
JDBCFeatureStore | Extends feature source with write capabilities |
FilterToSQL | Translates OGC filters to SQL WHERE clauses |
JDBCFeatureReader | Converts database results to features |
SQL Dialect System
The SQLDialect abstraction enables database-specific optimizations while providing a consistent API:
Each dialect handles:
- Type mapping between Java and SQL
- Geometry encoding/decoding
- Filter capabilities for the database
- Advanced database-specific operations
Filter Processing and SQL Generation
A key part of vector data processing is the translation of OGC Filter objects to SQL statements.
Filter Types and Capabilities
GeoTools supports various filter types for querying vector data:
| Filter Category | Examples | SQL Translation |
|---|---|---|
| Logical | And, Or, Not | AND, OR, NOT operators |
| Comparison | Equals, GreaterThan, LessThan | =, >, <, BETWEEN, etc. |
| Spatial | Intersects, Within, Contains | ST_Intersects, ST_Within, etc. |
| Temporal | After, Before, During | Date/time comparisons |
| ID | FeatureId | Primary key conditions |
| Arithmetic | Add, Subtract, Multiply | +, -, *, / operators |
Query Optimization
The vector processing system optimizes queries through several mechanisms:
- Filter splitting: Divides filters into parts handled by database vs. in-memory
- SQL generation: Produces optimized SQL based on database capabilities
- Prepared statements: Uses parameter binding for security and performance
- Spatial indexing: Leverages database spatial indexes when available
Database-Specific Vector Processing
GeoTools provides optimized implementations for different spatial databases through dialect implementations.
PostGIS Vector Processing
The PostGIS dialect provides specialized support for PostgreSQL with PostGIS:
- Native geometry type support (supporting all OGC geometry types)
- Spatial functions leveraging PostGIS capabilities
- Advanced features like curved geometries and 3D support
- JSON/JSONB support for storing and querying structured attributes
Key optimization techniques:
- Estimated extent usage for fast bounds computation
- TWKB (Tiny Well-Known Binary) for efficient geometry transfer
- Server-side simplification for large geometries
- Native JSON path querying for structured attributes
Oracle Spatial Support
The Oracle dialect supports Oracle's spatial capabilities:
- SDO_GEOMETRY type handling
- Oracle-specific spatial functions and operators
- Spatial metadata integration
- Optimization for Oracle's spatial indexing
Special handling exists for:
- Curved geometries in Oracle Spatial
- Geodetic data with specific distance calculations
- Oracle-specific SQL syntax and function calls
Complex Feature Processing
Beyond simple feature support, GeoTools provides mechanisms for working with complex feature models through the app-schema module.
App-Schema Architecture
The app-schema system maps between simple database features and complex feature models defined by application schemas:
- AppSchemaDataAccess: Main entry point for complex feature access
- FeatureTypeMapping: Maps source feature types to target complex types
- AttributeMapping: Defines mappings for individual attributes
- NestedAttributeMapping: Handles nested elements in complex features
- JoiningJDBCFeatureSource: Optimizes database access for feature chaining
Feature Chaining and Joining
One of the most powerful aspects of complex feature processing is the ability to chain features from different sources:
- Feature chaining: Links features based on key attributes
- Database joining: Optimizes access by performing SQL JOINs when possible
- XPath expressions: Used to map between simple and complex structures
The JoiningJDBCFeatureSource optimizes complex feature retrieval by:
- Performing SQL joins instead of multiple queries
- Preserving feature order for efficient chaining
- Handling custom join conditions and filtering
Advanced Vector Processing Techniques
Filtering and Expressions
GeoTools provides a rich expression system for vector data manipulation:
- PropertyName: Accesses feature attributes
- Functions: Performs calculations, transformations
- Literals: Represents constant values
- Arithmetic expressions: Math operations
These expressions are used in filters, transformations, and mappings for vector data processing.
Transaction Management
Vector editing is supported through transaction management:
- JDBCTransaction: Handles database-level transactions
- Transaction isolation: Controls visibility of changes
- AutoCommit vs. explicit: Support for both transaction models
- Batch processing: Optimized writes for multiple features
Aggregate Operations
The vector processing system supports efficient aggregation directly in the database:
- Count: Feature counting with filtering
- Min/Max: Finding extreme values for attributes
- Sum/Average: Statistical calculations
- GroupBy: Aggregation by category
These operations are optimized by pushing them to the database when possible, reducing data transfer and improving performance.
Performance Considerations
Optimizing vector data processing performance requires understanding several key factors:
- Query optimization: Use appropriate filters that can be pushed to the database
- Connection pooling: Configure connection pools appropriately for your workload
- Fetch size: Control how many features are retrieved at once (pagination)
- Spatial indexing: Ensure spatial indexes are used for spatial queries
- Attribute selection: Only request attributes that are needed
- Prepared statements: Use prepared statements for security and performance
The JDBCDataStore provides configuration options like:
fetchSize: Controls records fetched per database round-tripbatchInsertSize: Controls batch size for multiple insertsexposePrimaryKeyColumns: Controls whether primary keys are exposed as attributes
Integration with Other GeoTools Subsystems
Vector data processing integrates with other GeoTools subsystems:
- Rendering system: Vector features are rendered to maps
- Referencing system: For coordinate transformations
- Filter/Expression: For querying and manipulating data
- Schemas subsystem: For feature type definitions
- XML Bindings: For complex feature encoding/decoding
This integration allows vector data to flow seamlessly through the entire GeoTools processing pipeline.