Skip to content

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.

SVG
100%

JDBCDataStore Core Components ​

The JDBCDataStore serves as the main entry point for vector data access and has several key components:

ComponentPurpose
SQLDialectHandles database-specific operations and SQL generation
JDBCFeatureSourceProvides read access to vector features
JDBCFeatureStoreExtends feature source with write capabilities
FilterToSQLTranslates OGC filters to SQL WHERE clauses
JDBCFeatureReaderConverts database results to features

SQL Dialect System ​

The SQLDialect abstraction enables database-specific optimizations while providing a consistent API:

SVG
100%

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.

SVG
100%

Filter Types and Capabilities ​

GeoTools supports various filter types for querying vector data:

Filter CategoryExamplesSQL Translation
LogicalAnd, Or, NotAND, OR, NOT operators
ComparisonEquals, GreaterThan, LessThan=, >, <, BETWEEN, etc.
SpatialIntersects, Within, ContainsST_Intersects, ST_Within, etc.
TemporalAfter, Before, DuringDate/time comparisons
IDFeatureIdPrimary key conditions
ArithmeticAdd, Subtract, Multiply+, -, *, / operators

Query Optimization ​

The vector processing system optimizes queries through several mechanisms:

  1. Filter splitting: Divides filters into parts handled by database vs. in-memory
  2. SQL generation: Produces optimized SQL based on database capabilities
  3. Prepared statements: Uses parameter binding for security and performance
  4. 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.

SVG
100%

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:

  1. Feature chaining: Links features based on key attributes
  2. Database joining: Optimizes access by performing SQL JOINs when possible
  3. 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:

  1. Query optimization: Use appropriate filters that can be pushed to the database
  2. Connection pooling: Configure connection pools appropriately for your workload
  3. Fetch size: Control how many features are retrieved at once (pagination)
  4. Spatial indexing: Ensure spatial indexes are used for spatial queries
  5. Attribute selection: Only request attributes that are needed
  6. Prepared statements: Use prepared statements for security and performance

The JDBCDataStore provides configuration options like:

  • fetchSize: Controls records fetched per database round-trip
  • batchInsertSize: Controls batch size for multiple inserts
  • exposePrimaryKeyColumns: Controls whether primary keys are exposed as attributes

Integration with Other GeoTools Subsystems ​

Vector data processing integrates with other GeoTools subsystems:

  1. Rendering system: Vector features are rendered to maps
  2. Referencing system: For coordinate transformations
  3. Filter/Expression: For querying and manipulating data
  4. Schemas subsystem: For feature type definitions
  5. XML Bindings: For complex feature encoding/decoding

This integration allows vector data to flow seamlessly through the entire GeoTools processing pipeline.