CARLA
Loading...
Searching...
No Matches
Frame.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
9#include <string>
10
11namespace twinmodel {
12
13 /// WGS84 <-> local ENU metres, a transverse Mercator centred on the origin.
14 /// Ported from twinmodel/frame.py, which gets the same projection from pyproj.
15 class LocalFrame {
16 public:
17
18 LocalFrame() = default;
19
20 LocalFrame(double origin_lat, double origin_lon)
21 : _origin_lat(origin_lat), _origin_lon(origin_lon) {}
22
23 static LocalFrame FromBoundingBox(double south, double west, double north, double east) {
24 return LocalFrame((south + north) * 0.5, (west + east) * 0.5);
25 }
26
27 double GetOriginLatitude() const { return _origin_lat; }
28 double GetOriginLongitude() const { return _origin_lon; }
29
30 /// The +proj string written as the OpenDRIVE <geoReference>.
31 std::string GetProjString() const;
32
33 void ToLocal(double lon, double lat, double &x, double &y) const;
34 void ToWGS84(double x, double y, double &lon, double &lat) const;
35
36 private:
37
38 double _origin_lat = 0.0;
39 double _origin_lon = 0.0;
40 };
41
42} // namespace twinmodel
float y
float x
WGS84 <-> local ENU metres, a transverse Mercator centred on the origin.
Definition Frame.h:15
LocalFrame(double origin_lat, double origin_lon)
Definition Frame.h:20
void ToWGS84(double x, double y, double &lon, double &lat) const
Definition Frame.cpp:64
std::string GetProjString() const
The +proj string written as the OpenDRIVE <geoReference>.
Definition Frame.cpp:26
double GetOriginLongitude() const
Definition Frame.h:28
double GetOriginLatitude() const
Definition Frame.h:27
void ToLocal(double lon, double lat, double &x, double &y) const
Definition Frame.cpp:34
static LocalFrame FromBoundingBox(double south, double west, double north, double east)
Definition Frame.h:23