macro_rules! wkt {
($($wkt:tt)+) => { ... };
}
Expand description
Creates a crate::geometry
from a
WKT literal.
This is evaluated at compile time, so you don’t need to worry about runtime errors from invalid WKT syntax.
Note that POINT EMPTY
is not accepted because it is not representable as a geo_types::Point
.
Note that all geometry variants are constructable with this macro.
This includes LINE
, RECT
, and TRIANGLE
, even though they are
not standard WKT types, and will not be parsable by a standard WKT parser.
use geo_types::wkt;
let point = wkt! { POINT(1.0 2.0) };
assert_eq!(point.x(), 1.0);
assert_eq!(point.y(), 2.0);
let geometry_collection = wkt! {
GEOMETRYCOLLECTION(
POINT(1.0 2.0),
LINESTRING EMPTY,
POLYGON((0.0 0.0,1.0 0.0,1.0 1.0,0.0 0.0))
)
};
assert_eq!(geometry_collection.len(), 3);