tg_geom/lib.rs
1//! Rust bindings for the TG Geometry library.
2//!
3//! TG is a fast and lightweight geometry library for C that provides spatial
4//! operations including point-in-polygon, intersection tests, and more.
5//!
6//! # Quick Start
7//!
8//! ```rust,ignore
9//! use tg_geom::{Geom, GeomType, Point, init_mimalloc};
10//!
11//! // Initialize mimalloc allocator (requires `mimalloc` feature)
12//! init_mimalloc();
13//!
14//! // Create a point geometry
15//! let point = Geom::new_point(Point::new(1.0, 2.0)).unwrap();
16//! assert_eq!(point.geom_type(), GeomType::Point);
17//!
18//! // Parse from WKT
19//! let polygon = Geom::from_wkt("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))").unwrap();
20//!
21//! // Spatial predicates
22//! let test_point = Geom::new_point(Point::new(5.0, 5.0)).unwrap();
23//! assert!(polygon.contains(&test_point));
24//!
25//! // Export to different formats
26//! let geojson = polygon.to_geojson();
27//! let wkb = polygon.to_wkb();
28//! ```
29//!
30//! # Features
31//!
32//! - `mimalloc` - Use mimalloc as the memory allocator (recommended for
33//! performance)
34
35#[cfg(feature = "mimalloc")]
36mod allocator;
37mod error;
38mod geom;
39mod geom_type;
40mod index;
41mod line;
42mod parse;
43mod point;
44mod poly;
45mod rect;
46mod ring;
47mod segment;
48mod utils;
49
50#[cfg(feature = "mimalloc")]
51pub use allocator::init_mimalloc;
52pub use error::{Error, Result};
53pub use geom::{Geom, GeomRef};
54pub use geom_type::GeomType;
55pub use index::{IndexKind, set_default_index, set_default_index_spread, set_print_fixed_floats};
56pub use line::{Line, LineRef};
57pub use parse::{geobin_fullrect, geobin_point, geobin_rect};
58pub use point::Point;
59pub use poly::{Poly, PolyRef};
60pub use rect::Rect;
61pub use ring::{Ring, RingRef};
62pub use segment::Segment;