MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / geometry_from_wkt

Function geometry_from_wkt

nodedb-spatial/src/wkt.rs:71–90  ·  view source on GitHub ↗

Parse a WKT string into a Geometry. Returns `None` if the input is malformed.

(input: &str)

Source from the content-addressed store, hash-verified

69///
70/// Returns `None` if the input is malformed.
71pub fn geometry_from_wkt(input: &str) -> Option<Geometry> {
72 let s = input.trim();
73 if let Some(rest) = strip_prefix_ci(s, "GEOMETRYCOLLECTION") {
74 parse_geometry_collection(rest.trim())
75 } else if let Some(rest) = strip_prefix_ci(s, "MULTIPOLYGON") {
76 parse_multipolygon(rest.trim())
77 } else if let Some(rest) = strip_prefix_ci(s, "MULTILINESTRING") {
78 parse_multilinestring(rest.trim())
79 } else if let Some(rest) = strip_prefix_ci(s, "MULTIPOINT") {
80 parse_multipoint(rest.trim())
81 } else if let Some(rest) = strip_prefix_ci(s, "POLYGON") {
82 parse_polygon(rest.trim())
83 } else if let Some(rest) = strip_prefix_ci(s, "LINESTRING") {
84 parse_linestring(rest.trim())
85 } else if let Some(rest) = strip_prefix_ci(s, "POINT") {
86 parse_point(rest.trim())
87 } else {
88 None
89 }
90}
91
92// ── Serialization helpers ──
93

Callers 11

point_roundtripFunction · 0.85
linestring_roundtripFunction · 0.85
polygon_roundtripFunction · 0.85
multipoint_roundtripFunction · 0.85
multipolygon_roundtripFunction · 0.85
case_insensitive_parseFunction · 0.85
eval_geo_functionFunction · 0.85

Calls 8

parse_multipolygonFunction · 0.85
parse_multilinestringFunction · 0.85
parse_multipointFunction · 0.85
parse_polygonFunction · 0.85
parse_linestringFunction · 0.85
parse_pointFunction · 0.85
strip_prefix_ciFunction · 0.70

Tested by 9

point_roundtripFunction · 0.68
linestring_roundtripFunction · 0.68
polygon_roundtripFunction · 0.68
multipoint_roundtripFunction · 0.68
multipolygon_roundtripFunction · 0.68
case_insensitive_parseFunction · 0.68