Skip to main content

deep_causality/types/context_node_types/space/geo_space/
coordinate.rs

1/*
2 * SPDX-License-Identifier: MIT
3 * Copyright (c) 2023 - 2026. The DeepCausality Authors and Contributors. All Rights Reserved.
4 */
5
6use crate::errors::IndexError;
7use crate::{Coordinate, GeoSpace};
8
9impl Coordinate<f64> for GeoSpace {
10    fn dimension(&self) -> usize {
11        3
12    }
13
14    fn coordinate(&self, index: usize) -> Result<&f64, IndexError> {
15        match index {
16            0 => Ok(&self.lat),
17            1 => Ok(&self.lon),
18            2 => Ok(&self.alt),
19            _ => Err(IndexError(format!(
20                "Coordinate index out of bounds: {}",
21                index
22            ))),
23        }
24    }
25}