interior-point
Compute an interior point (representative point) of a geometry.
Ported from the JTS Topology Suite InteriorPoint algorithm. Uses geo / geo-types crates.
Usage
Add to Cargo.toml:
[]
= "0.3"
= "0.7"
or using cargo add:
use ;
use interior_point;
let poly = polygon!;
let pt = interior_point;
assert!;
An empty geometry returns None.
API
| Item | Signature | Returns |
|---|---|---|
interior_point |
(geometry: &Geometry<f64>) -> Option<Coord<f64>> |
a point inside area geometries, or on linear and point ones |
centroid_first_interior_point |
(geometry: &Geometry<f64>) -> Option<Coord<f64>> |
the geometry's centroid when it lies strictly inside, and interior_point when it does not |
verify_interior_point |
(point: Option<Coord<f64>>, geometry: Option<&Geometry<f64>>) -> Verification |
Interior, OnGeometry, OffGeometry or Unverifiable |
Those three functions and the Verification they answer with are the crate's whole public surface with the default features. Verification runs through a point-in-polygon locator that shares no code with the algorithm that produced the point, and checks this crate's own output rather than the input's OGC validity.
Full signatures, the four verification outcomes and the reasoning behind each entry point: API reference.
CLI
This crate also bundles an interior-point command-line binary, behind a cli feature that is
not in default; cargo install interior-point alone installs nothing, so build or install it
with --features cli:
It reads WKT or GeoJSON — as a literal, a file, or on stdin — and writes GeoJSON by default or one WKT geometry per line. See the CLI page for every flag, the output shapes and the exit codes.
Documentation
Full documentation: sanak.github.io/interior-point
License
This crate contains algorithms ported from JTS (EPL 2.0 / EDL 1.0).