[][src]Crate offset_polygon

An implementation of the polygon offsetting algorithm using winding numbers

Usage:

use geo_types::{LineString, Coordinate};
use offset_polygon::offset_polygon;
let input = LineString(vec![
    Coordinate {
        x: 0.0,
        y: 0.0,
    },
    Coordinate {
        x: 1.0,
        y: 0.0,
    },
    Coordinate {
        x: 1.0,
        y: 1.0,
    },
    Coordinate {
        x: 0.0,
        y: 0.0,
    },
]);
let result = offset_polygon(&input, -0.1, 10.0);
// result: Ok([[
//     Coordinate { x: 0.9, y: 0.1 },
//     Coordinate { x: 0.9, y: 0.7585786437626904 },
//     Coordinate { x: 0.24142135623730954, y: 0.1 },
//     Coordinate { x: 0.9, y: 0.1 }
// ]])

Note that polygons have to be closed (the last coordinate has to be the same as the first one), otherwise you will get some strange results.

Structs

CombinatorialExplosionError

Functions

offset_polygon

The core function of this crate. Expands or shrinks the given polygon by the offset. It support f32 and f64 for its calculations and input/output.