ecitygml_core/operations/
visitor.rs1use crate::model::building::Building;
2use crate::model::city_furniture::CityFurniture;
3use crate::model::city_model::CitygmlModel;
4use crate::model::construction::{
5 DoorSurface, GroundSurface, RoofSurface, WallSurface, WindowSurface,
6};
7use crate::model::solitary_vegetation_object::SolitaryVegetationObject;
8use crate::model::transportation::{
9 AuxiliaryTrafficArea, AuxiliaryTrafficSpace, Intersection, Road, Section, TrafficArea,
10 TrafficSpace,
11};
12
13pub trait Visitable {
14 fn accept<V: CityObjectVisitor>(&self, visitor: &mut V);
15}
16
17pub trait CityObjectVisitor {
18 type Result;
19
20 fn visit_city_model(&mut self, v: &CitygmlModel) -> Self::Result;
21
22 fn visit_city_furniture(&mut self, v: &CityFurniture) -> Self::Result;
23
24 fn visit_building(&mut self, v: &Building) -> Self::Result;
25 fn visit_roof_surface(&mut self, v: &RoofSurface) -> Self::Result;
26 fn visit_ground_surface(&mut self, v: &GroundSurface) -> Self::Result;
27 fn visit_wall_surface(&mut self, v: &WallSurface) -> Self::Result;
28 fn visit_window_surface(&mut self, v: &WindowSurface) -> Self::Result;
29 fn visit_door_surface(&mut self, v: &DoorSurface) -> Self::Result;
30
31 fn visit_solitary_vegetation_object(&mut self, v: &SolitaryVegetationObject) -> Self::Result;
32
33 fn visit_road(&mut self, v: &Road) -> Self::Result;
34 fn visit_section(&mut self, v: &Section) -> Self::Result;
35 fn visit_intersection(&mut self, v: &Intersection) -> Self::Result;
36 fn visit_traffic_space(&mut self, v: &TrafficSpace) -> Self::Result;
37 fn visit_auxiliary_traffic_space(&mut self, v: &AuxiliaryTrafficSpace) -> Self::Result;
38 fn visit_traffic_area(&mut self, v: &TrafficArea) -> Self::Result;
39 fn visit_auxiliary_traffic_area(&mut self, v: &AuxiliaryTrafficArea) -> Self::Result;
40}
41
42pub struct Interpreter;
43
44impl Default for Interpreter {
45 fn default() -> Self {
46 Self::new()
47 }
48}
49
50impl Interpreter {
51 pub fn new() -> Self {
52 Self {}
53 }
54}
55impl CityObjectVisitor for Interpreter {
56 type Result = ();
57
58 fn visit_city_model(&mut self, v: &CitygmlModel) -> Self::Result {
59 println!("hello city_model");
60 }
61
62 fn visit_city_furniture(&mut self, v: &CityFurniture) -> Self::Result {
63 println!(
64 "hello city_furniture {}",
65 v.occupied_space.space.city_object.gml.id
66 );
67 }
68
69 fn visit_building(&mut self, v: &Building) -> Self::Result {
70 println!("hello building {}", v.city_object.gml.id);
71 }
72
73 fn visit_roof_surface(&mut self, v: &RoofSurface) -> Self::Result {
74 println!(
75 "hello roof_surface {}",
76 v.thematic_surface.city_object.gml.id
77 );
78 }
79
80 fn visit_ground_surface(&mut self, v: &GroundSurface) -> Self::Result {
81 println!(
82 "hello ground_surface {}",
83 v.thematic_surface.city_object.gml.id
84 );
85 }
86
87 fn visit_wall_surface(&mut self, v: &WallSurface) -> Self::Result {
88 println!(
89 "hello wall_surface {}",
90 v.thematic_surface.city_object.gml.id
91 );
92 }
93
94 fn visit_window_surface(&mut self, v: &WindowSurface) -> Self::Result {
95 println!(
96 "hello window_surface {}",
97 v.occupied_space.space.city_object.gml.id
98 );
99 }
100
101 fn visit_door_surface(&mut self, v: &DoorSurface) -> Self::Result {
102 println!(
103 "hello door_surface {}",
104 v.occupied_space.space.city_object.gml.id
105 );
106 }
107
108 fn visit_solitary_vegetation_object(&mut self, v: &SolitaryVegetationObject) -> Self::Result {
109 println!(
110 "hello solitary_vegetation_object {}",
111 v.occupied_space.space.city_object.gml.id
112 );
113 }
114
115 fn visit_road(&mut self, v: &Road) -> Self::Result {
116 println!("hello road {}", v.city_object.gml.id);
117 }
118
119 fn visit_section(&mut self, v: &Section) -> Self::Result {
120 println!("hello section {}", v.city_object.gml.id);
121 }
122
123 fn visit_intersection(&mut self, v: &Intersection) -> Self::Result {
124 println!("hello intersection {}", v.city_object.gml.id);
125 }
126
127 fn visit_traffic_space(&mut self, v: &TrafficSpace) -> Self::Result {
128 println!("hello traffic_space {}", v.space.city_object.gml.id);
129 }
130
131 fn visit_auxiliary_traffic_space(&mut self, v: &AuxiliaryTrafficSpace) -> Self::Result {
132 println!(
133 "hello auxiliary_traffic_space {}",
134 v.space.city_object.gml.id
135 );
136 }
137
138 fn visit_traffic_area(&mut self, v: &TrafficArea) -> Self::Result {
139 println!(
140 "hello traffic_area {}",
141 v.thematic_surface.city_object.gml.id
142 );
143 }
144
145 fn visit_auxiliary_traffic_area(&mut self, v: &AuxiliaryTrafficArea) -> Self::Result {
146 println!(
147 "hello auxiliary_traffic_area {}",
148 v.thematic_surface.city_object.gml.id
149 );
150 }
151}