Rerun C++ SDK
Loading...
Searching...
No Matches
lat_lon.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/store/re_types/definitions/rerun/components/latlon.fbs".
3
4#pragma once
5
6#include "../component_descriptor.hpp"
7#include "../datatypes/dvec2d.hpp"
8#include "../result.hpp"
9
10#include <array>
11#include <cstdint>
12#include <memory>
13
14namespace rerun::components {
15 /// **Component**: A geospatial position expressed in [EPSG:4326](https://epsg.io/4326) latitude and longitude (North/East-positive degrees).
16 struct LatLon {
18
19 public: // START of extensions from lat_lon_ext.cpp:
20 /// Construct LatLon from x/y values.
21 LatLon(double lat, double lon) : lat_lon{lat, lon} {}
22
23 double latitude() const {
24 return lat_lon.x();
25 }
26
27 double longitude() const {
28 return lat_lon.y();
29 }
30
31 // END of extensions from lat_lon_ext.cpp, start of generated code:
32
33 public:
34 LatLon() = default;
35
36 LatLon(rerun::datatypes::DVec2D lat_lon_) : lat_lon(lat_lon_) {}
37
38 LatLon& operator=(rerun::datatypes::DVec2D lat_lon_) {
39 lat_lon = lat_lon_;
40 return *this;
41 }
42
43 LatLon(std::array<double, 2> xy_) : lat_lon(xy_) {}
44
45 LatLon& operator=(std::array<double, 2> xy_) {
46 lat_lon = xy_;
47 return *this;
48 }
49
50 /// Cast to the underlying DVec2D datatype
51 operator rerun::datatypes::DVec2D() const {
52 return lat_lon;
53 }
54 };
55} // namespace rerun::components
56
57namespace rerun {
58 static_assert(sizeof(rerun::datatypes::DVec2D) == sizeof(components::LatLon));
59
60 /// \private
61 template <>
62 struct Loggable<components::LatLon> {
63 static constexpr ComponentDescriptor Descriptor = "rerun.components.LatLon";
64
65 /// Returns the arrow data type this type corresponds to.
66 static const std::shared_ptr<arrow::DataType>& arrow_datatype() {
67 return Loggable<rerun::datatypes::DVec2D>::arrow_datatype();
68 }
69
70 /// Serializes an array of `rerun::components::LatLon` into an arrow array.
71 static Result<std::shared_ptr<arrow::Array>> to_arrow(
72 const components::LatLon* instances, size_t num_instances
73 ) {
74 if (num_instances == 0) {
75 return Loggable<rerun::datatypes::DVec2D>::to_arrow(nullptr, 0);
76 } else if (instances == nullptr) {
77 return rerun::Error(
78 ErrorCode::UnexpectedNullArgument,
79 "Passed array instances is null when num_elements> 0."
80 );
81 } else {
82 return Loggable<rerun::datatypes::DVec2D>::to_arrow(
83 &instances->lat_lon,
84 num_instances
85 );
86 }
87 }
88 };
89} // namespace rerun
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:95
All built-in components. See Types in the Rerun manual.
Definition rerun.hpp:80
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Component: A geospatial position expressed in EPSG:4326 latitude and longitude (North/East-positive d...
Definition lat_lon.hpp:16
LatLon(double lat, double lon)
Construct LatLon from x/y values.
Definition lat_lon.hpp:21
Datatype: A double-precision vector in 2D space.
Definition dvec2d.hpp:21