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