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

Function extract_geometry

nodedb/src/data/executor/handlers/spatial.rs:297–309  ·  view source on GitHub ↗

Extract geometry from a document field. Handles three storage forms: - `Value::Geometry(g)` — native geometry (columnar path preserves type) - `Value::String(s)` — GeoJSON string (from SQL ST_Point → serialized) - `Value::Object(_)` — GeoJSON object (from schemaless doc storage)

(doc: &Value, field: &str)

Source from the content-addressed store, hash-verified

295/// - `Value::String(s)` — GeoJSON string (from SQL ST_Point → serialized)
296/// - `Value::Object(_)` — GeoJSON object (from schemaless doc storage)
297fn extract_geometry(doc: &Value, field: &str) -> Option<nodedb_types::geometry::Geometry> {
298 let field_val = doc.get(field)?;
299 match field_val {
300 Value::Geometry(g) => Some(g.clone()),
301 Value::String(s) => sonic_rs::from_str(s).ok(),
302 Value::Object(map) => {
303 // GeoJSON object stored as Value::Object — serialize to JSON then parse.
304 let json = serde_json::Value::from(Value::Object(map.clone()));
305 serde_json::from_value(json).ok()
306 }
307 _ => None,
308 }
309}
310
311/// Apply the spatial predicate.
312fn apply_predicate(

Callers 2

execute_spatial_scanMethod · 0.85
spatial_full_scanMethod · 0.85

Calls 3

getMethod · 0.45
cloneMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected