Function skeleton_of_multi_polygon_to_linestring

Source
pub fn skeleton_of_multi_polygon_to_linestring(
    input_multi_polygon: &MultiPolygon,
    orientation: bool,
) -> Vec<LineString>
Expand description

This function returns a set of LineSting which represents an instantiated straight skeleton of the given multi-polygon. Each segment of the straight skeleton is represented as a single LineString, and the returned vector is a set of these LineStrings. If either endpoints of a LineString is infinitely far from the other, then this LineString will be clipped to one which has shorter length. The order of these LineStrings is arbitrary. (There is no gauranteed order on segments of the straight skeleton.)

Click ‘Result’ below to see how this function works.

§Arguments

  • input_multi_polygon: MultiPolygon to get the straight skeleton.
  • orientation: determines the region where the straight skeleton created. The value of this boolean variable will be:
    • true to create the staright skeleton on the inward region of the polygon, and,
    • false to create on the outward region of the polygon.

§Example

use geo_buffer::buffer_polygon;
use geo::{Polygon, MultiPolygon, LineString};

let p1 = Polygon::new(
    LineString::from(vec![(0., 0.), (2., 0.), (2., 2.), (0., 2.)]), vec![],
);
let p2 = Polygon::new(
    LineString::from(vec![(3., 3.), (5., 3.), (5., 5.), (3., 5.)]), vec![],
);
let mp1 = MultiPolygon::new(vec![p1, p2]);
let ls: Vec<LineString> = skeleton_of_multi_polygon_to_linestring(&mp1, false);
Result