Expand description
PostGIS Extended Well-Known Text (EWKT) reader and writer.
Not part of Boost.Geometry; follows the PostGIS manual, sections
“4.1.3. WKT and WKB” and “4.2.1. PostGIS EWKB and EWKT”, and the
PostGIS reader in liblwgeom/lwin_wkt_lex.l. EWKT is the dialect
ST_AsEWKT emits and ST_GeomFromEWKT accepts: OGC WKT plus an
optional SRID=<digits>; prefix and the glued dimension-suffix
spellings. ST_AsEWKT glues only M (POINTM(1 2 3)); PostGIS
reads the glued Z, M, and ZM forms and the OGC-spaced
POINT Z / POINT M / POINT ZM forms alike, and this crate reads
all of them.
The geometry body is delegated to geometry_io_wkt. This crate
scans the prefix, overwrites a glued suffix with spaces in place — a
same-length rewrite, so every byte offset it reports indexes the
string the caller passed — and hands the body over. from_ewkt
therefore emits a geometry_model::DynGeometry, and the six
parse_* conveniences return concrete model types; each is paired
with the spatial-reference id in an Ewkt.
PostGIS treats SRID 0 as unknown (Srid::UNKNOWN) and omits the
prefix for it. This crate reads SRID=0; as Some(Srid::UNKNOWN)
and writes it back as SRID=0;; callers pass None to omit the
prefix.
Every ordinate past the second is discarded, as in
geometry_io_wkt, and nothing above 2D is ever written — so a
dimension suffix carries no information this model can hold.
§Read and write a prefixed geometry
use geometry_io_ewkt::{Srid, from_ewkt, to_ewkt};
let e = from_ewkt("SRID=4326;POINTM(1 2 3)").unwrap();
assert_eq!(e.srid, Some(Srid::new(4326)));
assert_eq!(to_ewkt(&e.geometry, e.srid), "SRID=4326;POINT(1 2)");Structs§
- Ewkt
- A geometry together with the spatial-reference id that prefixed it.
- Srid
- A
PostGISspatial-reference id: the integer afterSRID=.
Enums§
- Ewkt
Error - Everything that can go wrong reading EWKT.
- WktError
- Everything that can go wrong reading WKT.
Functions§
- from_
ewkt - Read EWKT of any kind into a
DynGeometryand its SRID. - parse_
linestring - Read EWKT known to be a
LINESTRING. - parse_
multi_ linestring - Read EWKT known to be a
MULTILINESTRING. - parse_
multi_ point - Read EWKT known to be a
MULTIPOINT. - parse_
multi_ polygon - Read EWKT known to be a
MULTIPOLYGON. - parse_
point - Read EWKT known to be a
POINT. - parse_
polygon - Read EWKT known to be a
POLYGON. - to_ewkt
- Serialise a geometry and its SRID to canonical EWKT.
- to_
ewkt_ polygon - Serialise any polygon implementing the geometry traits, plus its SRID, to canonical EWKT.
- write_
ewkt - Serialise a geometry and its SRID into any
core::fmt::Writesink.