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
ato pointb.
Enums§
Functions§
- geobin_
fullrect - Extract N-dim bounding box from
GeoBinwithout full parsing. - geobin_
point - Extract point from
GeoBinwithout full parsing. - geobin_
rect - Extract rect from
GeoBinwithout full parsing. - set_
default_ index - set_
default_ index_ spread - set_
print_ fixed_ floats