[−][src]Macro geo_types::polygon
Creates a Polygon
containing the given coordinates.
polygon![Coordinate OR (x: <number>, y: <number>), …]
// or
polygon!(
exterior: [Coordinate OR (x: <number>, y: <number>), …],
interiors: [
[Coordinate OR (x: <number>, y: <number>), …],
…
],
)
Examples
Creating a Polygon
without interior rings, supplying x/y values:
use geo_types::polygon; let poly = polygon![ (x: -111., y: 45.), (x: -111., y: 41.), (x: -104., y: 41.), (x: -104., y: 45.), ]; assert_eq!( poly.exterior()[1], geo_types::Coordinate { x: -111., y: 41. }, );
Creating a Polygon
, supplying x/y values:
use geo_types::polygon; let poly = polygon!( exterior: [ (x: -111., y: 45.), (x: -111., y: 41.), (x: -104., y: 41.), (x: -104., y: 45.), ], interiors: [ [ (x: -110., y: 44.), (x: -110., y: 42.), (x: -105., y: 42.), (x: -105., y: 44.), ], ], ); assert_eq!( poly.exterior()[1], geo_types::Coordinate { x: -111., y: 41. }, );