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

Function geom_arg

nodedb-query/src/geo_functions.rs:367–379  ·  view source on GitHub ↗

Extract a geometry argument. Supports `Value::Geometry` directly, or falls back to JSON deserialization for `Value::Object` (GeoJSON).

(args: &[Value], idx: usize)

Source from the content-addressed store, hash-verified

365/// Extract a geometry argument. Supports `Value::Geometry` directly,
366/// or falls back to JSON deserialization for `Value::Object` (GeoJSON).
367fn geom_arg(args: &[Value], idx: usize) -> Option<nodedb_types::geometry::Geometry> {
368 match args.get(idx)? {
369 Value::Geometry(g) => Some(g.clone()),
370 // GeoJSON string: produced when a Geometry constant was round-tripped
371 // through the const-fold SqlValue path (e.g. ST_Distance(ST_Point(...), ST_Point(...))).
372 Value::String(s) => sonic_rs::from_str::<nodedb_types::geometry::Geometry>(s).ok(),
373 other => {
374 // Fallback: convert Value → JSON → Geometry for GeoJSON objects.
375 let json = serde_json::Value::from(other.clone());
376 serde_json::from_value(json).ok()
377 }
378 }
379}
380
381fn geo_predicate_2(
382 args: &[Value],

Callers 2

eval_geo_functionFunction · 0.85
geo_predicate_2Function · 0.85

Calls 3

getMethod · 0.45
cloneMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected