Skip to content

Commit fb6d6a5

Browse files
author
Andrei Popescu
authored
Adapts core/geo files to coding style. (#732)
This commit is the first of a series of coding style adapts to follow for the olp/geo folder, which is based on a legacy repository that was merged into this. This commit adapts GeoCoordinates, GeoCoordinates3d, GeoPoint, and GeoRectangle to coding style. Relates-to: OLPEDGE-569 Signed-off-by: Andrei Popescu <[email protected]>
1 parent cf37152 commit fb6d6a5

File tree

7 files changed

+201
-117
lines changed

7 files changed

+201
-117
lines changed

olp-cpp-sdk-core/include/olp/core/geo/coordinates/GeoCoordinates.h

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
namespace olp {
2727
namespace geo {
28+
2829
/**
2930
* @brief A geographic location using WGS84 coordinates.
3031
*
@@ -37,12 +38,13 @@ namespace geo {
3738
class CORE_API GeoCoordinates {
3839
public:
3940
/**
40-
* @brief Construct default geo coordinates
41+
* @brief Construct default invalid geo coordinates.
4142
*/
4243
GeoCoordinates();
4344

4445
/**
45-
* @brief Construct geo coordinates form latitude and longitude
46+
* @brief Construct geo coordinates form latitude and longitude.
47+
*
4648
* @param latitude_radians WGS84 latitude in radians. Valid values are in
4749
* [-Pi/2, Pi/2] range.
4850
* @param longitude_radians WGS84 longitude in radians. Valid values are in
@@ -51,7 +53,8 @@ class CORE_API GeoCoordinates {
5153
GeoCoordinates(double latitude_radians, double longitude_radians);
5254

5355
/**
54-
* @brief Construct geo coordinates form latitude and longitude in degrees
56+
* @brief Construct geo coordinates form latitude and longitude in degrees.
57+
*
5558
* @param latitude_degrees WGS84 latitude in degrees. Valid values are in
5659
* [-90, 90] range.
5760
* @param longitude_degrees WGS84 longitude in degrees. Valid values are in
@@ -63,10 +66,12 @@ class CORE_API GeoCoordinates {
6366

6467
/**
6568
* @brief Create GeoCoordinates from latitude and longitude in degrees.
69+
*
6670
* @param latitude_degrees WGS84 latitude in degrees. Valid value is in [-90,
6771
* 90] range.
6872
* @param longitude_degrees WGS84 longitude in degrees. Valid value is in
6973
* [-180, 180) range.
74+
*
7075
* @return GeoCoordinate based on specified input.
7176
* Use normalized() to put values in a valid range.
7277
*/
@@ -75,33 +80,42 @@ class CORE_API GeoCoordinates {
7580

7681
/**
7782
* @brief Create GeoCoordinates from GeoPoint.
83+
*
7884
* @param geo_point Geo point to convert to.
85+
*
7986
* @return GeoCoordinate based on specified geoPoint.
8087
*/
8188
static GeoCoordinates FromGeoPoint(const GeoPoint& geo_point);
8289

8390
/**
8491
* @brief Return geo coordinate as GeoPoint.
92+
*
8593
* @return current coordinate as a GeoPoint.
8694
*/
8795
GeoPoint ToGeoPoint() const;
8896

8997
/**
9098
* @brief Return WGS84 latitude in radians.
99+
*
91100
* @return WGS84 latitude in radians.
92101
*/
93102
double GetLatitude() const;
103+
94104
/**
95105
* @brief Set latitude in radians.
106+
*
96107
* @param latitude_radians WGS84 latitude in radians. Valid values are in
97108
* [-Pi/2, Pi/2] range.
98109
*/
99110
void SetLatitude(double latitude_radians);
111+
100112
/**
101113
* @brief Return WGS84 longitude in radians.
114+
*
102115
* @return WGS84 longitude in radians.
103116
*/
104117
double GetLongitude() const;
118+
105119
/**
106120
* @brief Set longitude in radians.
107121
* @param longitude_radians WGS84 longitude in radians. Valid values are in
@@ -111,54 +125,78 @@ class CORE_API GeoCoordinates {
111125

112126
/**
113127
* @brief Return WGS84 latitude in degrees.
128+
*
114129
* @return WGS84 latitude in degrees.
115130
*/
116131
double GetLatitudeDegrees() const;
117132

118133
/**
119134
* @brief Set latitude in degrees.
135+
*
120136
* @param latitude_degrees WGS84 latitude in degrees. Valid values are in
121137
* [-90, 90] range.
122138
*/
123139
void SetLatitudeDegrees(double latitude_degrees);
140+
124141
/**
125142
* @brief Return WGS84 longitude in degrees.
143+
*
126144
* @return WGS84 longitude in degrees.
127145
*/
128146
double GetLongitudeDegrees() const;
147+
129148
/**
130149
* @brief Set longitude in degrees.
150+
*
131151
* @param longitude_degrees WGS84 longitude in degrees. Valid values are in
132152
* [-180, 180) range.
133153
*/
134154
void SetLongitudeDegrees(double longitude_degrees);
135155

136156
/**
137157
* @brief Normalize the latitude and longitude to [-Pi/2, Pi/2], [-Pi, Pi)
138-
* range. To that end, longitude wraps around at +/- Pi and latitude is
139-
* clamped at +/- Pi/2
158+
* range.
159+
*
160+
* To that end, longitude wraps around at +/- Pi and latitude is clamped at
161+
* +/- Pi/2.
140162
*/
141163
GeoCoordinates Normalized() const;
164+
142165
/**
143-
* @brief Overload the bool operator. Return true if the coordinates are valid.
166+
* @brief Overload the bool operator.
167+
*
168+
* Returns true if the coordinates are valid.
169+
*
144170
* @see IsValid
145171
*/
146172
explicit operator bool() const;
173+
147174
/**
148175
* @brief Check if the radian values of latitude and longitude are valid
149-
* double numbers. The check happens with the help of math::isnan.
176+
* double numbers.
177+
*
178+
* The check happens with the help of math::isnan.
179+
*
150180
* @return true if the result of the check is positive,
151181
* false if it is negative.
152182
*/
153183
bool IsValid() const;
154184

155185
private:
156-
double latitude_; ///< Latitude in radians.
157-
double longitude_; ///< Longitude in radians.
186+
/// Latitude in radians.
187+
double latitude_;
188+
/// Longitude in radians.
189+
double longitude_;
190+
/// Const used to signalize an invalid value latitude or longitude.
158191
static const double kNaN_;
159192
};
160193

161-
bool operator==(const GeoCoordinates& lhs, const GeoCoordinates& rhs);
194+
/**
195+
* @brief Compare operator for comparing two coordinates with each other.
196+
*
197+
* @return true if the two GeoCoordinates are equal, false otherwise.
198+
*/
199+
CORE_API bool operator==(const GeoCoordinates& lhs, const GeoCoordinates& rhs);
162200

163201
} // namespace geo
164202
} // namespace olp

olp-cpp-sdk-core/include/olp/core/geo/coordinates/GeoCoordinates3d.h

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-2020 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,19 +24,23 @@
2424

2525
namespace olp {
2626
namespace geo {
27+
2728
/**
2829
* Geodetic coordinates with longitude, latitude and altitude.
2930
*/
3031
class CORE_API GeoCoordinates3d {
3132
public:
3233
/**
33-
* Construct invalid geodetic coordinates.
34+
* @brief Construct invalid geodetic coordinates.
35+
*
3436
* @post Latitude, longitude and altitude are undefined (NaN).
3537
*/
3638
GeoCoordinates3d();
3739

3840
/**
39-
* Construct geodetic coordinates from latitude, longitude and altitude.
41+
* @brief Construct geodetic coordinates from latitude, longitude and
42+
* altitude.
43+
*
4044
* @param[in] latitude_radians Latitude in radians.
4145
* @param[in] longitude_radians Longitude in radians.
4246
* @param[in] altitude_meters Altitude in meters.
@@ -45,133 +49,151 @@ class CORE_API GeoCoordinates3d {
4549
double altitude_meters);
4650

4751
/**
48-
* Construct geodetic coordinates from latitude, longitude and altitude.
52+
* @brief Construct geodetic coordinates from latitude, longitude and
53+
* altitude.
54+
*
4955
* @param[in] latitudeDegrees Latitude in degrees.
5056
* @param[in] longitudeDegrees Longitude in degrees.
5157
* @param[in] altitude_meters Altitude in meters.
5258
* @param[in] degrees Degree tag.
5359
*/
54-
GeoCoordinates3d(double latitudeDegrees, double longitudeDegrees,
60+
GeoCoordinates3d(double latitude_degrees, double longitude_degrees,
5561
double altitude_meters, DegreeType degrees);
5662

5763
/**
58-
* Construct geodetic coordinates from 2D coordinates with undefined altitude.
64+
* @brief Construct geodetic coordinates from 2D coordinates with undefined
65+
* altitude.
66+
*
5967
* @param[in] geo_coordinates 2D geodetic coordinates.
6068
* @post Altitude is undefined (NaN).
6169
*/
6270
explicit GeoCoordinates3d(const GeoCoordinates& geo_coordinates);
6371

6472
/**
65-
* Construct geodetic coordinates from 2D coordinates and an altitude.
73+
* @brief Construct geodetic coordinates from 2D coordinates and an altitude.
74+
*
6675
* @param[in] geo_coordinates 2D geodetic coordinates.
6776
* @param[in] altitude_meters Altitude in meters.
6877
*/
6978
GeoCoordinates3d(const GeoCoordinates& geo_coordinates,
7079
double altitude_meters);
7180

7281
/**
73-
* Create geodetic coordinates from latitude and longitude in degrees.
82+
* @brief Create geodetic coordinates from latitude and longitude in degrees.
83+
*
7484
* @param[in] latitude Latitude in degrees.
7585
* @param[in] longitude Longitude in degrees.
7686
* @param[in] altitude Altitude in meters.
7787
* @return Geodetic coordinates.
7888
*/
79-
static GeoCoordinates3d FromDegrees(double latitude,
80-
double longitude,
89+
static GeoCoordinates3d FromDegrees(double latitude, double longitude,
8190
double altitude = 0.0);
8291

8392
/**
84-
* Create geodetic coordinates from latitude and longitude in radians.
93+
* @brief Create geodetic coordinates from latitude and longitude in radians.
94+
*
8595
* @param[in] latitude Latitude in radians.
8696
* @param[in] longitude Longitude in radians.
8797
* @param[in] altitude Altitude in meters.
8898
* @return Geodetic coordinates.
8999
*/
90-
static GeoCoordinates3d FromRadians(double latitude,
91-
double longitude,
100+
static GeoCoordinates3d FromRadians(double latitude, double longitude,
92101
double altitude = 0.0);
93102

94103
/**
95104
* @brief Get latitude and longitude as 2D geodetic coordinates.
105+
*
96106
* @return 2D geodetic coordinates.
97107
*/
98108
const GeoCoordinates& GetGeoCoordinates() const;
99109

100110
/**
101111
* @brief Set latitude and longitude from 2D geodetic coordinates.
112+
*
102113
* @param[in] geo_coordinates 2D geodetic coordinates.
103114
*/
104115
void SetGeoCoordinates(const GeoCoordinates& geo_coordinates);
105116

106117
/**
107118
* @brief Get latitude.
119+
*
108120
* @return Latitude in radians.
109121
*/
110122
double GetLatitude() const;
111123

112124
/**
113-
* Set latitude.
125+
* @brief Set latitude.
126+
*
114127
* @param[in] latitude_radians Latitude in radians.
115128
*/
116129
void SetLatitude(double latitude_radians);
117130

118131
/**
119-
* Get longitude.
132+
* @brief Get longitude.
133+
*
120134
* @return Longitude in radians.
121135
*/
122136
double GetLongitude() const;
123137

124138
/**
125-
* Set longitude.
139+
* @brief Set longitude.
140+
*
126141
* @param[in] longitude_radians Longitude in radians.
127142
*/
128143
void SetLongitude(double longitude_radians);
129144

130145
/**
131-
* Get latitude in degrees.
146+
* @brief Get latitude in degrees.
147+
*
132148
* @return Latitude in degrees.
133149
*/
134150
double GetLatitudeDegrees() const;
135151

136152
/**
137-
* Set latitude in degrees.
153+
* @brief Set latitude in degrees.
154+
*
138155
* @param[in] latitude_degrees Latitude in degrees.
139156
*/
140157
void setLatitudeDegrees(double latitude_degrees);
141158

142159
/**
143-
* Get longitude in degrees.
160+
* @brief Get longitude in degrees.
144161
* @return Longitude in degrees.
145162
*/
146163
double GetLongitudeDegrees() const;
147164

148165
/**
149-
* Set longitude in degrees.
166+
* @brief Set longitude in degrees.
167+
*
150168
* @param[in] longitude_degrees Longitude in degrees.
151169
*/
152170
void SetLongitudeDegrees(double longitude_degrees);
153171

154172
/**
155-
* Get altitude.
173+
* @brief Get altitude.
174+
*
156175
* @return Altitude in meters.
157176
*/
158177
double GetAltitude() const;
159178

160179
/**
161-
* Set altitude.
180+
* @brief Set altitude.
181+
*
162182
* @param[in] altitude_meters Altitude in meters.
163183
*/
164184
void SetAltitude(double altitude_meters);
165185

166186
/**
167-
* Check whether coordinates and altitude are valid.
187+
* @brief Check whether coordinates and altitude are valid.
188+
*
168189
* @return True if all valid, false if latitude, longitude or altitude is
169190
* undefined.
170191
*/
171192
explicit operator bool() const;
172193

173194
/**
174-
* Check whether coordinates and altitude are valid.
195+
* @brief Check whether coordinates and altitude are valid.
196+
*
175197
* @return True if all valid, false if latitude, longitude or altitude is
176198
* undefined.
177199
*/

0 commit comments

Comments
 (0)