ecitygml_core/model/core/
abstract_feature.rs1use egml::model::base::Id;
2use egml::model::geometry::Envelope;
3
4#[derive(Debug, Clone, PartialEq)]
5pub struct AbstractFeature {
6 pub(crate) abstract_feature: egml::model::feature::AbstractFeature,
7}
8
9impl AbstractFeature {
10 pub fn new(id: Id) -> Self {
11 let abstract_gml = egml::model::base::AbstractGml::with_id(id);
12 let abstract_feature = egml::model::feature::AbstractFeature::new(abstract_gml);
13
14 Self { abstract_feature }
15 }
16
17 pub fn with_gml_abstract_feature(
18 abstract_feature: egml::model::feature::AbstractFeature,
19 ) -> Self {
20 Self { abstract_feature }
21 }
22
23 pub fn id(&self) -> &Id {
24 self.abstract_feature
25 .abstract_gml
26 .id
27 .as_ref()
28 .expect("id must be set for AbstractFeature")
29 }
30
31 pub fn name(&self) -> &Vec<String> {
32 &self.abstract_feature.abstract_gml.name
33 }
34
35 pub fn set_name(&mut self, name: Vec<String>) {
36 self.abstract_feature.abstract_gml.name = name;
37 }
38
39 pub fn bounded_by(&self) -> Option<&Envelope> {
40 self.abstract_feature.bounded_by.as_ref()
41 }
42
43 pub fn set_bounded_by(&mut self, bounded_by: Option<Envelope>) {
44 self.abstract_feature.bounded_by = bounded_by;
45 }
46}
47
48pub trait AsAbstractFeature {
49 fn abstract_feature(&self) -> &AbstractFeature;
50
51 fn id(&self) -> &Id {
52 self.abstract_feature().id()
53 }
54
55 fn name(&self) -> &Vec<String> {
56 self.abstract_feature().name()
57 }
58
59 fn bounded_by(&self) -> Option<&Envelope> {
60 self.abstract_feature().bounded_by()
61 }
62}
63
64pub trait AsAbstractFeatureMut: AsAbstractFeature {
65 fn abstract_feature_mut(&mut self) -> &mut AbstractFeature;
66
67 fn set_name(&mut self, name: Vec<String>) {
68 self.abstract_feature_mut().set_name(name);
69 }
70
71 fn set_bounded_by(&mut self, envelope: Option<Envelope>) {
72 self.abstract_feature_mut().set_bounded_by(envelope);
73 }
74}
75
76impl AsAbstractFeature for AbstractFeature {
77 fn abstract_feature(&self) -> &AbstractFeature {
78 self
79 }
80}
81
82impl AsAbstractFeatureMut for AbstractFeature {
83 fn abstract_feature_mut(&mut self) -> &mut AbstractFeature {
84 self
85 }
86}