Skip to main content

egml_core/model/base/
association_attributes.rs

1use crate::model::basic_types::NilReason;
2use crate::model::xlink::{ActuateType, HRef, ShowType};
3
4/// Attributes from `gml:AssociationAttributeGroup`.
5///
6/// A property either holds an inline geometry object or references one via
7/// [`href`](AssociationAttributes::href).
8/// [`nil_reason`](AssociationAttributes::nil_reason) explains why a value is absent
9/// when neither is provided.
10///
11/// Corresponds to `gml:AssociationAttributeGroup` in
12/// [OGC 07-036 §7.2.3.1](https://docs.ogc.org/is/07-036/07-036.pdf).
13#[derive(Debug, Clone, PartialEq, Default)]
14pub struct AssociationAttributes {
15    /// `xlink:href` — reference to a remote or local GML object.
16    pub href: Option<HRef>,
17    /// `gml:nilReason` — explanation for a missing or void value.
18    pub nil_reason: Option<NilReason>,
19    /// `xlink:title` — human-readable label for the remote resource.
20    pub title: Option<String>,
21    /// `xlink:role` — URI identifying the semantic role of the remote resource.
22    pub role: Option<String>,
23    /// `xlink:arcrole` — URI identifying the semantic role of the link arc.
24    pub arcrole: Option<String>,
25    /// `xlink:show` — desired presentation of the remote resource on traversal.
26    pub show: Option<ShowType>,
27    /// `xlink:actuate` — timing of link traversal.
28    pub actuate: Option<ActuateType>,
29}
30
31impl AssociationAttributes {
32    /// Creates an `AssociationAttributes` carrying only an `xlink:href` reference.
33    pub fn new_href(href: HRef) -> Self {
34        Self {
35            href: Some(href),
36            ..Default::default()
37        }
38    }
39
40    /// Returns the local GML `gml:id` referenced by `href`.
41    ///
42    /// Returns `None` if `href` is absent or is a remote reference.
43    pub fn local_id(&self) -> Option<&str> {
44        self.href.as_ref()?.local_id()
45    }
46}