Extract a geometry argument. Supports `Value::Geometry` directly, or falls back to JSON deserialization for `Value::Object` (GeoJSON).
(args: &[Value], idx: usize)
| 365 | /// Extract a geometry argument. Supports `Value::Geometry` directly, |
| 366 | /// or falls back to JSON deserialization for `Value::Object` (GeoJSON). |
| 367 | fn 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 | |
| 381 | fn geo_predicate_2( |
| 382 | args: &[Value], |
no test coverage detected