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)
| 295 | /// - `Value::String(s)` — GeoJSON string (from SQL ST_Point → serialized) |
| 296 | /// - `Value::Object(_)` — GeoJSON object (from schemaless doc storage) |
| 297 | fn 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. |
| 312 | fn apply_predicate( |
no test coverage detected