Crates.io | geo-wkt-writer |
lib.rs | geo-wkt-writer |
version | 0.1.1 |
source | src |
created_at | 2020-04-15 15:32:46.563924 |
updated_at | 2020-04-20 13:17:13.292831 |
description | A trait to serialize geo-type Geometry types to WKT representation |
homepage | https://gitlab.com/bronsonbdevost/rust-geo-wkt-writer |
repository | https://gitlab.com/bronsonbdevost/rust-geo-wkt-writer |
max_upload_size | |
id | 230545 |
size | 17,638 |
A trait for geo-types Geometries to output a WKT representation.
This trait applies to all Geometry types in geo-types. There is no Rect or Triangle WKT text type, so both of those will be serialized as POLYGON WKT representations. Any polygons returned will be normalized.
use geo_types::{Geometry, GeometryCollection, polygon, point};
use geo_wkt_writer::ToWkt;
let poly = Geometry::Polygon(polygon![
(x: 1.0, y: 1.0),
(x: 4.0, y: 1.0),
(x: 4.0, y: 4.0),
(x: 1.0, y: 4.0),
(x: 1.0, y: 1.0),
]);
let pe = Geometry::Point(point!(x: 1.0, y: 1.0));
let gc = GeometryCollection(vec![pe, poly]);
let wkt_out = gc.to_wkt();
let expected = String::from("GEOMETRYCOLLECTION(POINT(1 1),POLYGON((1 1,4 1,4 4,1 4,1 1)))");
assert_eq!(wkt_out, expected);