Crate tg_geom

Crate tg_geom 

Source
Expand description

Rust bindings for the TG Geometry library.

TG is a fast and lightweight geometry library for C that provides spatial operations including point-in-polygon, intersection tests, and more.

§Quick Start

use tg_geom::{Geom, GeomType, Point, init_mimalloc};

// Initialize mimalloc allocator (requires `mimalloc` feature)
init_mimalloc();

// Create a point geometry
let point = Geom::new_point(Point::new(1.0, 2.0)).unwrap();
assert_eq!(point.geom_type(), GeomType::Point);

// Parse from WKT
let polygon = Geom::from_wkt("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))").unwrap();

// Spatial predicates
let test_point = Geom::new_point(Point::new(5.0, 5.0)).unwrap();
assert!(polygon.contains(&test_point));

// Export to different formats
let geojson = polygon.to_geojson();
let wkb = polygon.to_wkb();

§Features

  • mimalloc - Use mimalloc as the memory allocator (recommended for performance)

Structs§

Geom
An owned geometry that can represent any OGC Simple Feature type.
GeomRef
A borrowed reference to a geometry.
Line
An owned line string.
LineRef
A borrowed reference to a line string.
Point
X and Y coordinates.
Poly
An owned polygon.
PolyRef
A borrowed reference to a polygon.
Rect
Defined by minimum and maximum corner points.
Ring
An owned closed ring.
RingRef
A borrowed reference to a ring.
Segment
Directed from point a to point b.

Enums§

Error
GeomType
IndexKind

Functions§

geobin_fullrect
Extract N-dim bounding box from GeoBin without full parsing.
geobin_point
Extract point from GeoBin without full parsing.
geobin_rect
Extract rect from GeoBin without full parsing.
set_default_index
set_default_index_spread
set_print_fixed_floats

Type Aliases§

Result