Rerun C++ SDK
Loading...
Searching...
No Matches
geo_points.hpp
1// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/build/re_type_definitions/rerun/archetypes/geo_points.def.rs".
3
4#pragma once
5
6#include "../archetype_utils.hpp"
7#include "../collection.hpp"
8#include "../component_batch.hpp"
9#include "../component_column.hpp"
10#include "../components/class_id.hpp"
11#include "../components/color.hpp"
12#include "../components/lat_lon.hpp"
13#include "../components/radius.hpp"
14#include "../result.hpp"
15
16#include <cstdint>
17#include <optional>
18#include <utility>
19#include <vector>
20
21namespace rerun::archetypes {
22 /// **Archetype**: Geospatial points with positions expressed in [EPSG:4326](https://epsg.io/4326) latitude and longitude (North/East-positive degrees), and optional colors and radii.
23 ///
24 /// ## Example
25 ///
26 /// ### Log a geospatial point
27 /// ![image](https://static.rerun.io/geopoint_simple/b86ce83e5871837587bd33a0ad639358b96e9010/full.png)
28 ///
29 /// ```cpp
30 /// #include <rerun.hpp>
31 ///
32 /// int main(int argc, char* argv[]) {
33 /// const auto rec = rerun::RecordingStream("rerun_example_geo_points");
34 /// rec.spawn().exit_on_failure();
35 ///
36 /// rec.log(
37 /// "rerun_hq",
38 /// rerun::GeoPoints::from_lat_lon({{59.319221, 18.075631}})
39 /// .with_radii(rerun::Radius::ui_points(10.0f))
40 /// .with_colors(rerun::Color(255, 0, 0))
41 /// );
42 /// }
43 /// ```
44 struct GeoPoints {
45 /// The [EPSG:4326](https://epsg.io/4326) coordinates for the points (North/East-positive degrees).
46 std::optional<ComponentBatch> positions;
47
48 /// Optional radii for the points, effectively turning them into circles.
49 ///
50 /// *Note*: scene units radiii are interpreted as meters.
51 std::optional<ComponentBatch> radii;
52
53 /// Optional colors for the points.
54 std::optional<ComponentBatch> colors;
55
56 /// Optional class Ids for the points.
57 ///
58 /// The `components::ClassId` provides colors if not specified explicitly.
59 std::optional<ComponentBatch> class_ids;
60
61 public:
62 /// The name of the archetype as used in `ComponentDescriptor`s.
63 static constexpr const char ArchetypeName[] = "rerun.archetypes.GeoPoints";
64
65 /// `ComponentDescriptor` for the `positions` field.
68 );
69 /// `ComponentDescriptor` for the `radii` field.
70 static constexpr auto Descriptor_radii = ComponentDescriptor(
72 );
73 /// `ComponentDescriptor` for the `colors` field.
74 static constexpr auto Descriptor_colors = ComponentDescriptor(
76 );
77 /// `ComponentDescriptor` for the `class_ids` field.
79 ArchetypeName, "GeoPoints:class_ids",
81 );
82
83 public: // START of extensions from geo_points_ext.cpp:
84 /// Creates a new GeoPoints object based on [EPSG:4326](https://epsg.io/4326) latitude and longitude (North/East-positive degrees).
86 return GeoPoints(std::move(positions_));
87 }
88
89 // END of extensions from geo_points_ext.cpp, start of generated code:
90
91 public:
92 GeoPoints() = default;
93 GeoPoints(GeoPoints&& other) = default;
94 GeoPoints(const GeoPoints& other) = default;
95 GeoPoints& operator=(const GeoPoints& other) = default;
96 GeoPoints& operator=(GeoPoints&& other) = default;
97
99 : positions(ComponentBatch::from_loggable(std::move(_positions), Descriptor_positions)
100 .value_or_throw()) {}
101
102 /// Update only some specific fields of a `GeoPoints`.
104 return GeoPoints();
105 }
106
107 /// Clear all the fields of a `GeoPoints`.
109
110 /// The [EPSG:4326](https://epsg.io/4326) coordinates for the points (North/East-positive degrees).
112 positions =
113 ComponentBatch::from_loggable(_positions, Descriptor_positions).value_or_throw();
114 return std::move(*this);
115 }
116
117 /// Optional radii for the points, effectively turning them into circles.
118 ///
119 /// *Note*: scene units radiii are interpreted as meters.
121 radii = ComponentBatch::from_loggable(_radii, Descriptor_radii).value_or_throw();
122 return std::move(*this);
123 }
124
125 /// Optional colors for the points.
127 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
128 return std::move(*this);
129 }
130
131 /// Optional class Ids for the points.
132 ///
133 /// The `components::ClassId` provides colors if not specified explicitly.
135 class_ids =
136 ComponentBatch::from_loggable(_class_ids, Descriptor_class_ids).value_or_throw();
137 return std::move(*this);
138 }
139
140 /// Partitions the component data into multiple sub-batches.
141 ///
142 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
143 /// instead, via `ComponentBatch::partitioned`.
144 ///
145 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
146 ///
147 /// The specified `lengths` must sum to the total length of the component batch.
149 return detail::partition_batches({&positions, &radii, &colors, &class_ids}, lengths_)
150 .value_or_throw();
151 }
152
153 /// Partitions the component data into unit-length sub-batches.
154 ///
155 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
156 /// where `n` is automatically guessed.
158 return detail::partition_batches_of_unit_length({&positions, &radii, &colors, &class_ids
159 })
160 .value_or_throw();
161 }
162 };
163
164} // namespace rerun::archetypes
165
166namespace rerun {
167 /// \private
168 template <typename T>
169 struct AsComponents;
170
171 /// \private
172 template <>
173 struct AsComponents<archetypes::GeoPoints> {
174 /// Serialize all set component batches.
175 static Result<Collection<ComponentBatch>> as_batches(const archetypes::GeoPoints& archetype
176 ) {
177 return detail::collect_batches(
178 {&archetype.positions, &archetype.radii, &archetype.colors, &archetype.class_ids}
179 );
180 }
181 };
182} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:90
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:26
Arrow-encoded data of a single batch of components together with a component descriptor.
Definition component_batch.hpp:28
static Result< ComponentBatch > from_loggable(const rerun::Collection< T > &components, const ComponentDescriptor &descriptor)
Creates a new component batch from a collection of component instances.
Definition component_batch.hpp:46
A ComponentDescriptor fully describes the semantics of a column of data.
Definition component_descriptor.hpp:16
The Loggable trait is used by all built-in implementation of rerun::AsComponents to serialize a colle...
Definition loggable.hpp:11
Archetype: Geospatial points with positions expressed in EPSG:4326 latitude and longitude (North/East...
Definition geo_points.hpp:44
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
Definition geo_points.hpp:148
GeoPoints with_positions(const Collection< rerun::components::LatLon > &_positions) &&
The EPSG:4326 coordinates for the points (North/East-positive degrees).
Definition geo_points.hpp:111
std::optional< ComponentBatch > radii
Optional radii for the points, effectively turning them into circles.
Definition geo_points.hpp:51
GeoPoints with_class_ids(const Collection< rerun::components::ClassId > &_class_ids) &&
Optional class Ids for the points.
Definition geo_points.hpp:134
std::optional< ComponentBatch > class_ids
Optional class Ids for the points.
Definition geo_points.hpp:59
static constexpr auto Descriptor_radii
ComponentDescriptor for the radii field.
Definition geo_points.hpp:70
static constexpr auto Descriptor_class_ids
ComponentDescriptor for the class_ids field.
Definition geo_points.hpp:78
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition geo_points.hpp:63
static GeoPoints update_fields()
Update only some specific fields of a GeoPoints.
Definition geo_points.hpp:103
GeoPoints with_radii(const Collection< rerun::components::Radius > &_radii) &&
Optional radii for the points, effectively turning them into circles.
Definition geo_points.hpp:120
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition geo_points.hpp:74
static GeoPoints from_lat_lon(Collection< components::LatLon > positions_)
Creates a new GeoPoints object based on EPSG:4326 latitude and longitude (North/East-positive degrees...
Definition geo_points.hpp:85
std::optional< ComponentBatch > positions
The EPSG:4326 coordinates for the points (North/East-positive degrees).
Definition geo_points.hpp:46
GeoPoints with_colors(const Collection< rerun::components::Color > &_colors) &&
Optional colors for the points.
Definition geo_points.hpp:126
static GeoPoints clear_fields()
Clear all the fields of a GeoPoints.
std::optional< ComponentBatch > colors
Optional colors for the points.
Definition geo_points.hpp:54
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
Definition geo_points.hpp:157
static constexpr auto Descriptor_positions
ComponentDescriptor for the positions field.
Definition geo_points.hpp:66