#wkt #gis #graphics

geo-wkt-writer

A trait to serialize geo-type Geometry types to WKT representation

2 releases

0.1.1 Apr 20, 2020
0.1.0 Apr 15, 2020

#5 in #wkt

Download history 72/week @ 2024-11-13 124/week @ 2024-11-20 83/week @ 2024-11-27 116/week @ 2024-12-04 54/week @ 2024-12-11 16/week @ 2024-12-18 76/week @ 2025-01-08 33/week @ 2025-01-15 252/week @ 2025-01-22 101/week @ 2025-01-29 435/week @ 2025-02-05 366/week @ 2025-02-12 288/week @ 2025-02-19 80/week @ 2025-02-26

1,171 downloads per month
Used in geo-repair-polygon

MIT license

16KB
355 lines

rust-geo-wkt-writer

A trait for geo-types Geometries to output a WKT representation.

ToWkt

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.

Examples

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);

Dependencies

~2MB
~41K SLoC