1#![allow(unused_braces)]
5#![allow(unused_imports)]
6#![allow(unused_parens)]
7#![allow(clippy::clone_on_copy)]
8#![allow(clippy::cloned_instead_of_copied)]
9#![allow(clippy::map_flatten)]
10#![allow(clippy::needless_question_mark)]
11#![allow(clippy::new_without_default)]
12#![allow(clippy::redundant_closure)]
13#![allow(clippy::too_many_arguments)]
14#![allow(clippy::too_many_lines)]
15
16use ::re_types_core::try_serialize_field;
17use ::re_types_core::SerializationResult;
18use ::re_types_core::{ComponentBatch as _, SerializedComponentBatch};
19use ::re_types_core::{ComponentDescriptor, ComponentType};
20use ::re_types_core::{DeserializationError, DeserializationResult};
21
22#[derive(Clone, Debug, PartialEq, Default)]
51pub struct GeoPoints {
52 pub positions: Option<SerializedComponentBatch>,
54
55 pub radii: Option<SerializedComponentBatch>,
59
60 pub colors: Option<SerializedComponentBatch>,
62
63 pub class_ids: Option<SerializedComponentBatch>,
67}
68
69impl GeoPoints {
70 #[inline]
74 pub fn descriptor_positions() -> ComponentDescriptor {
75 ComponentDescriptor {
76 archetype: Some("rerun.archetypes.GeoPoints".into()),
77 component: "GeoPoints:positions".into(),
78 component_type: Some("rerun.components.LatLon".into()),
79 }
80 }
81
82 #[inline]
86 pub fn descriptor_radii() -> ComponentDescriptor {
87 ComponentDescriptor {
88 archetype: Some("rerun.archetypes.GeoPoints".into()),
89 component: "GeoPoints:radii".into(),
90 component_type: Some("rerun.components.Radius".into()),
91 }
92 }
93
94 #[inline]
98 pub fn descriptor_colors() -> ComponentDescriptor {
99 ComponentDescriptor {
100 archetype: Some("rerun.archetypes.GeoPoints".into()),
101 component: "GeoPoints:colors".into(),
102 component_type: Some("rerun.components.Color".into()),
103 }
104 }
105
106 #[inline]
110 pub fn descriptor_class_ids() -> ComponentDescriptor {
111 ComponentDescriptor {
112 archetype: Some("rerun.archetypes.GeoPoints".into()),
113 component: "GeoPoints:class_ids".into(),
114 component_type: Some("rerun.components.ClassId".into()),
115 }
116 }
117}
118
119static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> =
120 once_cell::sync::Lazy::new(|| [GeoPoints::descriptor_positions()]);
121
122static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 2usize]> =
123 once_cell::sync::Lazy::new(|| {
124 [
125 GeoPoints::descriptor_radii(),
126 GeoPoints::descriptor_colors(),
127 ]
128 });
129
130static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> =
131 once_cell::sync::Lazy::new(|| [GeoPoints::descriptor_class_ids()]);
132
133static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 4usize]> =
134 once_cell::sync::Lazy::new(|| {
135 [
136 GeoPoints::descriptor_positions(),
137 GeoPoints::descriptor_radii(),
138 GeoPoints::descriptor_colors(),
139 GeoPoints::descriptor_class_ids(),
140 ]
141 });
142
143impl GeoPoints {
144 pub const NUM_COMPONENTS: usize = 4usize;
146}
147
148impl ::re_types_core::Archetype for GeoPoints {
149 #[inline]
150 fn name() -> ::re_types_core::ArchetypeName {
151 "rerun.archetypes.GeoPoints".into()
152 }
153
154 #[inline]
155 fn display_name() -> &'static str {
156 "Geo points"
157 }
158
159 #[inline]
160 fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
161 REQUIRED_COMPONENTS.as_slice().into()
162 }
163
164 #[inline]
165 fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
166 RECOMMENDED_COMPONENTS.as_slice().into()
167 }
168
169 #[inline]
170 fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
171 OPTIONAL_COMPONENTS.as_slice().into()
172 }
173
174 #[inline]
175 fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
176 ALL_COMPONENTS.as_slice().into()
177 }
178
179 #[inline]
180 fn from_arrow_components(
181 arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
182 ) -> DeserializationResult<Self> {
183 re_tracing::profile_function!();
184 use ::re_types_core::{Loggable as _, ResultExt as _};
185 let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
186 let positions = arrays_by_descr
187 .get(&Self::descriptor_positions())
188 .map(|array| {
189 SerializedComponentBatch::new(array.clone(), Self::descriptor_positions())
190 });
191 let radii = arrays_by_descr
192 .get(&Self::descriptor_radii())
193 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_radii()));
194 let colors = arrays_by_descr
195 .get(&Self::descriptor_colors())
196 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_colors()));
197 let class_ids = arrays_by_descr
198 .get(&Self::descriptor_class_ids())
199 .map(|array| {
200 SerializedComponentBatch::new(array.clone(), Self::descriptor_class_ids())
201 });
202 Ok(Self {
203 positions,
204 radii,
205 colors,
206 class_ids,
207 })
208 }
209}
210
211impl ::re_types_core::AsComponents for GeoPoints {
212 #[inline]
213 fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
214 use ::re_types_core::Archetype as _;
215 [
216 self.positions.clone(),
217 self.radii.clone(),
218 self.colors.clone(),
219 self.class_ids.clone(),
220 ]
221 .into_iter()
222 .flatten()
223 .collect()
224 }
225}
226
227impl ::re_types_core::ArchetypeReflectionMarker for GeoPoints {}
228
229impl GeoPoints {
230 #[inline]
232 pub(crate) fn new(
233 positions: impl IntoIterator<Item = impl Into<crate::components::LatLon>>,
234 ) -> Self {
235 Self {
236 positions: try_serialize_field(Self::descriptor_positions(), positions),
237 radii: None,
238 colors: None,
239 class_ids: None,
240 }
241 }
242
243 #[inline]
245 pub fn update_fields() -> Self {
246 Self::default()
247 }
248
249 #[inline]
251 pub fn clear_fields() -> Self {
252 use ::re_types_core::Loggable as _;
253 Self {
254 positions: Some(SerializedComponentBatch::new(
255 crate::components::LatLon::arrow_empty(),
256 Self::descriptor_positions(),
257 )),
258 radii: Some(SerializedComponentBatch::new(
259 crate::components::Radius::arrow_empty(),
260 Self::descriptor_radii(),
261 )),
262 colors: Some(SerializedComponentBatch::new(
263 crate::components::Color::arrow_empty(),
264 Self::descriptor_colors(),
265 )),
266 class_ids: Some(SerializedComponentBatch::new(
267 crate::components::ClassId::arrow_empty(),
268 Self::descriptor_class_ids(),
269 )),
270 }
271 }
272
273 #[inline]
284 pub fn columns<I>(
285 self,
286 _lengths: I,
287 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>>
288 where
289 I: IntoIterator<Item = usize> + Clone,
290 {
291 let columns = [
292 self.positions
293 .map(|positions| positions.partitioned(_lengths.clone()))
294 .transpose()?,
295 self.radii
296 .map(|radii| radii.partitioned(_lengths.clone()))
297 .transpose()?,
298 self.colors
299 .map(|colors| colors.partitioned(_lengths.clone()))
300 .transpose()?,
301 self.class_ids
302 .map(|class_ids| class_ids.partitioned(_lengths.clone()))
303 .transpose()?,
304 ];
305 Ok(columns.into_iter().flatten())
306 }
307
308 #[inline]
313 pub fn columns_of_unit_batches(
314 self,
315 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>> {
316 let len_positions = self.positions.as_ref().map(|b| b.array.len());
317 let len_radii = self.radii.as_ref().map(|b| b.array.len());
318 let len_colors = self.colors.as_ref().map(|b| b.array.len());
319 let len_class_ids = self.class_ids.as_ref().map(|b| b.array.len());
320 let len = None
321 .or(len_positions)
322 .or(len_radii)
323 .or(len_colors)
324 .or(len_class_ids)
325 .unwrap_or(0);
326 self.columns(std::iter::repeat(1).take(len))
327 }
328
329 #[inline]
331 pub fn with_positions(
332 mut self,
333 positions: impl IntoIterator<Item = impl Into<crate::components::LatLon>>,
334 ) -> Self {
335 self.positions = try_serialize_field(Self::descriptor_positions(), positions);
336 self
337 }
338
339 #[inline]
343 pub fn with_radii(
344 mut self,
345 radii: impl IntoIterator<Item = impl Into<crate::components::Radius>>,
346 ) -> Self {
347 self.radii = try_serialize_field(Self::descriptor_radii(), radii);
348 self
349 }
350
351 #[inline]
353 pub fn with_colors(
354 mut self,
355 colors: impl IntoIterator<Item = impl Into<crate::components::Color>>,
356 ) -> Self {
357 self.colors = try_serialize_field(Self::descriptor_colors(), colors);
358 self
359 }
360
361 #[inline]
365 pub fn with_class_ids(
366 mut self,
367 class_ids: impl IntoIterator<Item = impl Into<crate::components::ClassId>>,
368 ) -> Self {
369 self.class_ids = try_serialize_field(Self::descriptor_class_ids(), class_ids);
370 self
371 }
372}
373
374impl ::re_byte_size::SizeBytes for GeoPoints {
375 #[inline]
376 fn heap_size_bytes(&self) -> u64 {
377 self.positions.heap_size_bytes()
378 + self.radii.heap_size_bytes()
379 + self.colors.heap_size_bytes()
380 + self.class_ids.heap_size_bytes()
381 }
382}