CARLA
Loading...
Searching...
No Matches
GeoProjection.h
Go to the documentation of this file.
1// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8#include <string>
10
11#ifdef _MSC_VER
12#pragma warning(push)
13#pragma warning(disable:4583)
14#pragma warning(disable:4582)
15#include <boost/variant2/variant.hpp>
16#pragma warning(pop)
17#else
18#include <boost/variant2/variant.hpp>
19#endif
20
21namespace carla {
22namespace geom {
23
24 struct Location;
25 class Transform;
26 class GeoLocation;
27
28 /// All the supported projection types. To add new ones, add them to this enum,
29 /// create the parameters structure and the parser from geo to location (and viceversa).
36
37 using ProjectionParams = boost::variant2::variant<
42
44
45 template <typename T>
46 static GeoProjection Make(T&& args)
47 {
48 GeoProjection r = { };
49 r.params = ProjectionParams(std::forward<T>(args));
50 return r;
51 }
52
53 /// Get the type of projection.
55 return static_cast<ProjectionType>(params.index());
56 }
57
58 /// Get the parameters.
59 const ProjectionParams& GetParams() const {
60 return params;
61 }
62
63 /// Set the Proj raw string.
64 void SetPROJString(std::string s) {
65 proj_string = std::move(s);
66 }
67
68 /// Get the Proj raw string.
69 const std::string& GetPROJString() const {
70 return proj_string;
71 }
72
73 // Projection parameters.
75
76 /// Proj string reference.
77 std::string proj_string;
78
79 /// Transform the given location to a geo location.
80 Location GeoLocationToTransform(const GeoLocation& geolocation) const;
81
82 /// Transform the given geo location to a location using TransverseMercator.
84 const GeoLocation& geolocation, const TransverseMercatorParams params) const;
85
86 /// Transform the given geo location to a location using UniversalTransverseMercator.
88 const GeoLocation& geolocation, const UniversalTransverseMercatorParams params) const;
89
90 /// Transform the given geo location to a location using WebMercator.
92 const GeoLocation& geolocation, const WebMercatorParams params) const;
93
94 /// Transform the given geo location to a location using LambertConformalConic.
96 const GeoLocation& geolocation, const LambertConformalConicParams params) const;
97
98 /// Transform the given geo location to a location.
99 GeoLocation TransformToGeoLocation(const Location& location) const;
100
101 /// Transform the given location to a geo location using TransverseMercator.
103 const Location& location, const TransverseMercatorParams params) const;
104
105 /// Transform the given location to a geo location using UniversalTransverseMercator.
107 const Location& location, const UniversalTransverseMercatorParams) const;
108
109 /// Transform the given location to a geo location using WebMercator.
111 const Location& location, const WebMercatorParams params) const;
112
113 /// Transform the given location to a geo location using LambertConformalConic.
115 const Location& location, const LambertConformalConicParams params) const;
116
117 };
118} // namespace geom
119} // namespace carla
ProjectionType
All the supported projection types.
boost::variant2::variant< TransverseMercatorParams, UniversalTransverseMercatorParams, WebMercatorParams, LambertConformalConicParams > ProjectionParams
geom::Location Location
geom::Transform Transform
This file contains definitions of common data structures used in traffic manager.
ProjectionType GetType() const
Get the type of projection.
GeoLocation TransformToGeoLocationUniversalTransverseMercator(const Location &location, const UniversalTransverseMercatorParams) const
Transform the given location to a geo location using UniversalTransverseMercator.
Location GeoLocationToTransformUniversalTransverseMercator(const GeoLocation &geolocation, const UniversalTransverseMercatorParams params) const
Transform the given geo location to a location using UniversalTransverseMercator.
GeoLocation TransformToGeoLocationLambertConformalConic(const Location &location, const LambertConformalConicParams params) const
Transform the given location to a geo location using LambertConformalConic.
const ProjectionParams & GetParams() const
Get the parameters.
GeoLocation TransformToGeoLocationTransverseMercator(const Location &location, const TransverseMercatorParams params) const
Transform the given location to a geo location using TransverseMercator.
void SetPROJString(std::string s)
Set the Proj raw string.
Location GeoLocationToTransformLambertConformalConic(const GeoLocation &geolocation, const LambertConformalConicParams params) const
Transform the given geo location to a location using LambertConformalConic.
Location GeoLocationToTransform(const GeoLocation &geolocation) const
Transform the given location to a geo location.
GeoLocation TransformToGeoLocationWebMercator(const Location &location, const WebMercatorParams params) const
Transform the given location to a geo location using WebMercator.
const std::string & GetPROJString() const
Get the Proj raw string.
Location GeoLocationToTransformTransverseMercator(const GeoLocation &geolocation, const TransverseMercatorParams params) const
Transform the given geo location to a location using TransverseMercator.
GeoLocation TransformToGeoLocation(const Location &location) const
Transform the given geo location to a location.
static GeoProjection Make(T &&args)
Location GeoLocationToTransformWebMercator(const GeoLocation &geolocation, const WebMercatorParams params) const
Transform the given geo location to a location using WebMercator.
std::string proj_string
Proj string reference.