Skip to main content

Crate oxigdal_algorithms

Crate oxigdal_algorithms 

Source
Expand description

OxiGDAL Algorithms - High-Performance Raster and Vector Operations

This crate provides production-ready geospatial algorithms for raster and vector processing, with a focus on performance, correctness, and Pure Rust implementation.

§Features

§Resampling Algorithms

  • Nearest neighbor (fast, preserves exact values)
  • Bilinear interpolation (smooth, good for continuous data)
  • Bicubic interpolation (high quality, slower)
  • Lanczos resampling (highest quality, expensive)

§Raster Operations

  • Raster calculator (map algebra with expression evaluation)
  • Hillshade generation (3D terrain visualization)
  • Slope and aspect calculation (terrain analysis)
  • Reclassification (value mapping and binning)
  • Zonal statistics (aggregate statistics by zones)

§Vector Operations

§Geometric Operations

  • Buffer generation (fixed and variable distance, multiple cap/join styles)
  • Intersection (geometric intersection with sweep line algorithm)
  • Union (geometric union, cascaded union, convex hull)
  • Difference (geometric difference, symmetric difference, clip to box)

§Simplification

  • Douglas-Peucker simplification (perpendicular distance based)
  • Visvalingam-Whyatt simplification (area based)
  • Topology-preserving simplification

§Geometric Analysis

  • Centroid calculation (geometric and area-weighted, all geometry types)
  • Area calculation (planar and geodetic methods)
  • Distance measurement (Euclidean, Haversine, Vincenty)

§Spatial Predicates

  • Contains, Within (point-in-polygon tests)
  • Intersects, Disjoint (intersection tests)
  • Touches, Overlaps (boundary relationships)

§Validation

  • Geometry validation (OGC Simple Features compliance)
  • Self-intersection detection
  • Duplicate vertex detection
  • Ring orientation and closure checks

§SIMD Optimizations

Many algorithms use SIMD instructions (when enabled) for maximum performance. Enable the simd feature for best performance.

§Examples

§Raster Resampling

use oxigdal_algorithms::resampling::{ResamplingMethod, Resampler};
use oxigdal_core::buffer::RasterBuffer;
use oxigdal_core::types::RasterDataType;

// Create source raster
let src = RasterBuffer::zeros(1000, 1000, RasterDataType::Float32);

// Resample to half size using bilinear interpolation
let resampler = Resampler::new(ResamplingMethod::Bilinear);
let dst = resampler.resample(&src, 500, 500)?;

§Vector Operations

use oxigdal_algorithms::{
    Coordinate, LineString, Point, Polygon,
    buffer_point, BufferOptions,
    area, area_polygon, AreaMethod,
    centroid_polygon, simplify_linestring, SimplifyMethod,
    validate_polygon,
};

// Create a point and buffer it
let point = Point::new(0.0, 0.0);
let options = BufferOptions::default();
let buffered = buffer_point(&point, 10.0, &options)?;

// Calculate area of a polygon
let coords = vec![
    Coordinate::new_2d(0.0, 0.0),
    Coordinate::new_2d(10.0, 0.0),
    Coordinate::new_2d(10.0, 10.0),
    Coordinate::new_2d(0.0, 10.0),
    Coordinate::new_2d(0.0, 0.0),
];
let exterior = LineString::new(coords)?;
let polygon = Polygon::new(exterior, vec![])?;
let area_value = area_polygon(&polygon, AreaMethod::Planar)?;

// Simplify a linestring
let line_coords = vec![
    Coordinate::new_2d(0.0, 0.0),
    Coordinate::new_2d(1.0, 0.1),
    Coordinate::new_2d(2.0, -0.05),
    Coordinate::new_2d(3.0, 0.0),
];
let linestring = LineString::new(line_coords)?;
let simplified = simplify_linestring(&linestring, 0.15, SimplifyMethod::DouglasPeucker)?;

// Validate a polygon
let issues = validate_polygon(&polygon)?;
assert!(issues.is_empty()); // Valid square has no issues

§Performance

All algorithms are designed for production use with:

  • Zero-copy operations where possible
  • SIMD vectorization (x86_64 AVX2, ARM NEON)
  • Cache-friendly memory access patterns
  • Optional parallel processing via rayon

§COOLJAPAN Policy Compliance

  • Pure Rust (no C/Fortran dependencies)
  • No unwrap() or expect() in production code
  • Comprehensive error handling
  • no_std compatible core algorithms (with alloc)

Re-exports§

pub use error::AlgorithmError;
pub use error::Result;
pub use resampling::Resampler;
pub use resampling::ResamplingMethod;
pub use vector::AreaMethod;
pub use vector::BufferCapStyle;
pub use vector::BufferJoinStyle;
pub use vector::BufferOptions;
pub use vector::ContainsPredicate;
pub use vector::DistanceMethod;
pub use vector::IntersectsPredicate;
pub use vector::IssueType;
pub use vector::SegmentIntersection;
pub use vector::Severity;
pub use vector::SimplifyMethod;
pub use vector::TouchesPredicate;
pub use vector::ValidationIssue;
pub use vector::area;
pub use vector::area_multipolygon;
pub use vector::area_polygon;
pub use vector::buffer_linestring;
pub use vector::buffer_point;
pub use vector::buffer_polygon;
pub use vector::cascaded_union;
pub use vector::centroid;
pub use vector::centroid_collection;
pub use vector::centroid_linestring;
pub use vector::centroid_multilinestring;
pub use vector::centroid_multipoint;
pub use vector::centroid_multipolygon;
pub use vector::centroid_point;
pub use vector::centroid_polygon;
pub use vector::clip_to_box;
pub use vector::clustering;
pub use vector::contains;
pub use vector::convex_hull;
pub use vector::delaunay;
pub use vector::difference_polygon;
pub use vector::difference_polygons;
pub use vector::disjoint;
pub use vector::distance_point_to_linestring;
pub use vector::distance_point_to_point;
pub use vector::distance_point_to_polygon;
pub use vector::erase_small_holes;
pub use vector::intersect_linestrings;
pub use vector::intersect_linestrings_sweep;
pub use vector::intersect_polygons;
pub use vector::intersect_segment_segment;
pub use vector::intersects;
pub use vector::is_clockwise;
pub use vector::is_counter_clockwise;
pub use vector::merge_polygons;
pub use vector::network;
pub use vector::point_in_polygon;
pub use vector::point_in_polygon_or_boundary;
pub use vector::point_on_polygon_boundary;
pub use vector::point_strictly_inside_polygon;
pub use vector::simplify_linestring;
pub use vector::simplify_linestring_dp;
pub use vector::simplify_polygon;
pub use vector::spatial_join;
pub use vector::symmetric_difference;
pub use vector::topology;
pub use vector::touches;
pub use vector::union_polygon;
pub use vector::union_polygons;
pub use vector::validate_geometry;
pub use vector::validate_linestring;
pub use vector::validate_polygon;
pub use vector::voronoi;
pub use vector::within;

Modules§

dsl
Advanced Raster Algebra Domain-Specific Language (DSL)
error
Error types for OxiGDAL algorithms
raster
Raster processing operations
resampling
Raster resampling algorithms
simd
SIMD (Single Instruction Multiple Data) optimizations for performance-critical operations
tutorials
Algorithm Tutorials and Guides
vector
Vector operations and geometric algorithms

Macros§

dsl_function
Helper macro for defining custom DSL functions
raster
Macro for compile-time raster algebra expressions

Structs§

Coordinate
Coordinate in 2D, 3D, or 4D space
LineString
LineString geometry
MultiPolygon
MultiPolygon geometry
Point
Point geometry
Polygon
Polygon geometry

Constants§

NAME
Crate name
VERSION
Crate version