Skip to main content

spatialrust_semantic/
entity.rs

1//! Semantic spatial entities.
2
3use spatialrust_math::Vec3;
4
5use crate::Embedding;
6
7/// Stable entity identifier.
8#[derive(Clone, Debug, PartialEq, Eq, Hash)]
9pub struct EntityId(pub String);
10
11impl EntityId {
12    /// Creates an entity id.
13    #[must_use]
14    pub fn new(value: impl Into<String>) -> Self {
15        Self(value.into())
16    }
17}
18
19/// Open-vocabulary label with confidence.
20#[derive(Clone, Debug, PartialEq)]
21pub struct OpenVocabLabel {
22    /// Free-form text label.
23    pub text: String,
24    /// Confidence in `[0, 1]`.
25    pub confidence: f32,
26}
27
28/// One semantic spatial entity with optional embedding.
29#[derive(Clone, Debug, PartialEq)]
30pub struct SemanticEntity {
31    /// Entity id.
32    pub id: EntityId,
33    /// Optional centroid.
34    pub centroid: Option<Vec3<f32>>,
35    /// Open-vocabulary labels.
36    pub labels: Vec<OpenVocabLabel>,
37    /// Optional embedding for search/fusion.
38    pub embedding: Option<Embedding>,
39}