Skip to content

A trait to collate LineStrings into Polygons, for the rust geo crate

License

Notifications You must be signed in to change notification settings

jsadusk/geo-collate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

geo-collate

Polygon collation for the Rust geo types.

What is polygon collation?

Polygon collation is converting an unorganized set of closed LineStrings, and organizing them into a set of Polygons. This isn't trivial, because you have to identify which LineStrings are holes, and which are exteriors, and which holes belong to which exteriors.

Example

let exterior1: LineString<i64> = vec![(0, 0), (0, 30), (30, 30), (30, 0), (0, 0)].into();
let hole1: LineString<i64> = vec![(10, 10), (20, 10), (20, 20), (10, 20), (10, 10)].into();
let exterior2: LineString<i64> = exterior1.translate(40, 0);

let hole2: LineString<i64> = hole1.translate(40, 0);

let uncollated: MultiLineString<i64> = (vec![exterior1, hole1, exterior2, hole2])
    .into_iter()
    .collect();
let collated: MultiPolygon<i64> = uncollated.collate().unwrap();

About

A trait to collate LineStrings into Polygons, for the rust geo crate

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages