Skip to content

Commit

Permalink
Simplify Orient example
Browse files Browse the repository at this point in the history
  • Loading branch information
urschrei committed Dec 24, 2018
1 parent 904b78c commit e6d1481
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions geo/src/algorithm/orient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@ pub trait Orient<T> {
/// use geo::{Point, LineString, Polygon};
/// use geo::orient::{Orient, Direction};
/// // a diamond shape, oriented clockwise outside
/// let points_ext_raw = vec![(1.0, 0.0), (0.0, 1.0), (1.0, 2.0), (2.0, 1.0), (1.0, 0.0)];
/// let points_ext = vec![(1.0, 0.0), (0.0, 1.0), (1.0, 2.0), (2.0, 1.0), (1.0, 0.0)];
/// // counter-clockwise interior
/// let points_int_raw = vec![(1.0, 0.5), (1.5, 1.0), (1.0, 1.5), (0.5, 1.0), (1.0, 0.5)];
/// let points_ext = points_ext_raw.iter().map(|e| Point::new(e.0, e.1)).collect::<Vec<_>>();
/// let points_int = points_int_raw.iter().map(|e| Point::new(e.0, e.1)).collect::<Vec<_>>();
/// let points_int = vec![(1.0, 0.5), (1.5, 1.0), (1.0, 1.5), (0.5, 1.0), (1.0, 0.5)];
/// let poly = Polygon::new(LineString::from(points_ext), vec![LineString::from(points_int)]);
/// // a diamond shape, oriented counter-clockwise outside,
/// let oriented_ext = vec![(1.0, 0.0), (2.0, 1.0), (1.0, 2.0), (0.0, 1.0), (1.0, 0.0)];
/// let oriented_ext_ls = LineString::from(oriented_ext.iter().map(|e| Point::new(e.0, e.1)).collect::<Vec<_>>());
/// let oriented_ext_ls = LineString::from(oriented_ext);
/// // clockwise interior
/// let oriented_int = vec![(1.0, 0.5), (0.5, 1.0), (1.0, 1.5), (1.5, 1.0), (1.0, 0.5)];
/// let oriented_int_ls = LineString::from(oriented_int.iter().map(|e| Point::new(e.0, e.1)).collect::<Vec<_>>());
/// let oriented_int_ls = LineString::from(oriented_int);
/// // build corrected Polygon
/// let oriented = poly.orient(Direction::Default);
/// assert_eq!(oriented.exterior.0, oriented_ext_ls.0);
Expand Down

0 comments on commit e6d1481

Please sign in to comment.