Skip to content

Commit 0be2028

Browse files
author
Andrei Popescu
authored
Adapts core/geo/projection files to coding style. (#733)
This commit adapts the following files to the coding style: Types.h, EquirectangularProjection.h, IdentityProjection.h SphereProjection.h and IProjection.h. Relates-to: OLPEDGE-569 Signed-off-by: Andrei Popescu <[email protected]>
1 parent d0faf61 commit 0be2028

File tree

8 files changed

+82
-78
lines changed

8 files changed

+82
-78
lines changed

olp-cpp-sdk-core/include/olp/core/geo/Types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class WebMercatorProjection;
4646
using WorldAlignedBox = math::AlignedBox3d;
4747
using WorldCoordinates = math::Vector3d;
4848

49-
struct DegreeType {};
49+
struct CORE_API DegreeType {};
5050

5151
} // namespace geo
5252
} // namespace olp

olp-cpp-sdk-core/include/olp/core/geo/projection/EquirectangularProjection.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ namespace geo {
3838
class CORE_API EquirectangularProjection final : public IProjection {
3939
public:
4040
EquirectangularProjection() = default;
41+
~EquirectangularProjection() override = default;
4142

4243
GeoRectangle GetGeoBounds() const override;
4344

@@ -46,6 +47,7 @@ class CORE_API EquirectangularProjection final : public IProjection {
4647

4748
bool Project(const GeoCoordinates3d& geo_point,
4849
WorldCoordinates& world_point) const override;
50+
4951
bool Unproject(const WorldCoordinates& world_point,
5052
GeoCoordinates3d& geo_point) const override;
5153
};

olp-cpp-sdk-core/include/olp/core/geo/projection/IProjection.h

Lines changed: 7 additions & 3 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.
@@ -23,17 +23,21 @@
2323

2424
namespace olp {
2525
namespace geo {
26+
2627
class CORE_API IProjection {
2728
public:
2829
virtual ~IProjection() = default;
2930

3031
/**
31-
* Get geodetic bounds representable by projection
32+
* @brief Get geodetic bounds representable by projection.
33+
*
3234
* @return Geodetic rectangle
3335
*/
3436
virtual GeoRectangle GetGeoBounds() const = 0;
3537

36-
/** Extent of world coordinates */
38+
/**
39+
* @brief Extent of world coordinates.
40+
*/
3741
virtual WorldAlignedBox WorldExtent(double minimum_altitude,
3842
double maximum_altitude) const = 0;
3943

olp-cpp-sdk-core/include/olp/core/geo/projection/IdentityProjection.h

Lines changed: 3 additions & 1 deletion
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.
@@ -31,6 +31,7 @@ namespace geo {
3131
class CORE_API IdentityProjection final : public IProjection {
3232
public:
3333
IdentityProjection() = default;
34+
~IdentityProjection() override = default;
3435

3536
GeoRectangle GetGeoBounds() const override;
3637

@@ -39,6 +40,7 @@ class CORE_API IdentityProjection final : public IProjection {
3940

4041
bool Project(const GeoCoordinates3d& geo_point,
4142
WorldCoordinates& world_point) const override;
43+
4244
bool Unproject(const WorldCoordinates& world_point,
4345
GeoCoordinates3d& geo_point) const override;
4446
};

olp-cpp-sdk-core/include/olp/core/geo/projection/SphereProjection.h

Lines changed: 4 additions & 1 deletion
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,6 +24,7 @@
2424

2525
namespace olp {
2626
namespace geo {
27+
2728
/**
2829
* @brief Projection of geo coordinates onto a sphere using earth radius.
2930
*
@@ -40,6 +41,7 @@ namespace geo {
4041
class CORE_API SphereProjection final : public IProjection {
4142
public:
4243
SphereProjection() = default;
44+
~SphereProjection() override = default;
4345

4446
GeoRectangle GetGeoBounds() const override;
4547

@@ -48,6 +50,7 @@ class CORE_API SphereProjection final : public IProjection {
4850

4951
bool Project(const GeoCoordinates3d& geo_point,
5052
WorldCoordinates& world_point) const override;
53+
5154
bool Unproject(const WorldCoordinates& world_point,
5255
GeoCoordinates3d& geo_point) const override;
5356
};

olp-cpp-sdk-core/src/geo/projection/EquirectangularProjection.cpp

Lines changed: 20 additions & 22 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.
@@ -17,37 +17,35 @@
1717
* License-Filename: LICENSE
1818
*/
1919

20-
#include <olp/core/geo/projection/EquirectangularProjection.h>
20+
#include "olp/core/geo/projection/EquirectangularProjection.h"
2121

22-
#include <olp/core/geo/coordinates/GeoCoordinates3d.h>
23-
#include <olp/core/geo/coordinates/GeoRectangle.h>
24-
#include <olp/core/geo/projection/EarthConstants.h>
25-
#include <olp/core/math/AlignedBox.h>
26-
#include <olp/core/math/Math.h>
22+
#include "olp/core/geo/Types.h"
23+
#include "olp/core/geo/coordinates/GeoCoordinates3d.h"
24+
#include "olp/core/geo/coordinates/GeoRectangle.h"
25+
#include "olp/core/geo/projection/EarthConstants.h"
26+
#include "olp/core/math/AlignedBox.h"
27+
#include "olp/core/math/Math.h"
2728

2829
namespace olp {
29-
30-
using namespace math;
31-
3230
namespace geo {
3331
namespace {
34-
constexpr double WORLD_TO_GEO_SCALE = two_pi;
35-
constexpr double GEO_TO_WORLD_SCALE = 1.0 / WORLD_TO_GEO_SCALE;
32+
constexpr double kWorldToGeoScale = math::two_pi;
33+
constexpr double kGeoToWorldScale = 1.0 / kWorldToGeoScale;
3634

37-
Vector3d toWorld(const GeoCoordinates3d& geo_coords) {
38-
return {(geo_coords.GetLongitude() + pi) * GEO_TO_WORLD_SCALE,
39-
(geo_coords.GetLatitude() + half_pi) * GEO_TO_WORLD_SCALE,
40-
geo_coords.GetAltitude()};
35+
WorldCoordinates ToWorldCoordinates(const GeoCoordinates3d& geo_coordinates) {
36+
return {(geo_coordinates.GetLongitude() + math::pi) * kGeoToWorldScale,
37+
(geo_coordinates.GetLatitude() + math::half_pi) * kGeoToWorldScale,
38+
geo_coordinates.GetAltitude()};
4139
}
4240

43-
GeoCoordinates3d toGeodetic(const Vector3d& point) {
44-
return {point.y * WORLD_TO_GEO_SCALE - half_pi,
45-
point.x * WORLD_TO_GEO_SCALE - pi, point.z};
41+
GeoCoordinates3d ToGeoCoordinates(const WorldCoordinates& point) {
42+
return {point.y * kWorldToGeoScale - math::half_pi,
43+
point.x * kWorldToGeoScale - math::pi, point.z};
4644
}
4745
} // namespace
4846

4947
GeoRectangle EquirectangularProjection::GetGeoBounds() const {
50-
return {{-half_pi, -pi}, {+half_pi, +pi}};
48+
return {{-math::half_pi, -math::pi}, {+math::half_pi, +math::pi}};
5149
}
5250

5351
WorldAlignedBox EquirectangularProjection::WorldExtent(
@@ -58,13 +56,13 @@ WorldAlignedBox EquirectangularProjection::WorldExtent(
5856

5957
bool EquirectangularProjection::Project(const GeoCoordinates3d& geo_point,
6058
WorldCoordinates& world_point) const {
61-
world_point = toWorld(geo_point);
59+
world_point = ToWorldCoordinates(geo_point);
6260
return true;
6361
}
6462

6563
bool EquirectangularProjection::Unproject(const WorldCoordinates& world_point,
6664
GeoCoordinates3d& geo_point) const {
67-
geo_point = toGeodetic(world_point);
65+
geo_point = ToGeoCoordinates(world_point);
6866
return true;
6967
}
7068

olp-cpp-sdk-core/src/geo/projection/IdentityProjection.cpp

Lines changed: 17 additions & 19 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.
@@ -17,50 +17,48 @@
1717
* License-Filename: LICENSE
1818
*/
1919

20-
#include <olp/core/geo/projection/IdentityProjection.h>
20+
#include "olp/core/geo/projection/IdentityProjection.h"
2121

22-
#include <olp/core/geo/coordinates/GeoCoordinates.h>
23-
#include <olp/core/geo/coordinates/GeoCoordinates3d.h>
24-
#include <olp/core/geo/coordinates/GeoRectangle.h>
25-
#include <olp/core/math/AlignedBox.h>
26-
#include <olp/core/math/Math.h>
22+
#include "olp/core/geo/Types.h"
23+
#include "olp/core/geo/coordinates/GeoCoordinates.h"
24+
#include "olp/core/geo/coordinates/GeoCoordinates3d.h"
25+
#include "olp/core/geo/coordinates/GeoRectangle.h"
26+
#include "olp/core/math/AlignedBox.h"
27+
#include "olp/core/math/Math.h"
2728

2829
namespace olp {
29-
30-
using namespace math;
31-
3230
namespace geo {
3331
namespace {
3432

35-
Vector3d toWorld(const GeoCoordinates3d& geo_coords) {
36-
return {geo_coords.GetLongitude(), geo_coords.GetLatitude(),
37-
geo_coords.GetAltitude()};
33+
WorldCoordinates ToWorldCoordinates(const GeoCoordinates3d& geo_coordinates) {
34+
return {geo_coordinates.GetLongitude(), geo_coordinates.GetLatitude(),
35+
geo_coordinates.GetAltitude()};
3836
}
39-
GeoCoordinates3d toGeodetic(const Vector3d& point) {
37+
GeoCoordinates3d ToGeoCoordinates(const WorldCoordinates& point) {
4038
return {point.y, point.x, point.z};
4139
}
4240
} // namespace
4341

4442
GeoRectangle IdentityProjection::GetGeoBounds() const {
45-
return {{-half_pi, -pi}, {+half_pi, +pi}};
43+
return {{-math::half_pi, -math::pi}, {+math::half_pi, +math::pi}};
4644
}
4745

4846
WorldAlignedBox IdentityProjection::WorldExtent(double minimum_altitude,
4947
double maximum_altitude) const {
50-
WorldCoordinates min(-pi, -half_pi, minimum_altitude);
51-
WorldCoordinates max(pi, half_pi, maximum_altitude);
48+
WorldCoordinates min(-math::pi, -math::half_pi, minimum_altitude);
49+
WorldCoordinates max(math::pi, math::half_pi, maximum_altitude);
5250
return WorldAlignedBox(min, max);
5351
}
5452

5553
bool IdentityProjection::Project(const GeoCoordinates3d& geo_point,
5654
WorldCoordinates& world_point) const {
57-
world_point = toWorld(geo_point);
55+
world_point = ToWorldCoordinates(geo_point);
5856
return true;
5957
}
6058

6159
bool IdentityProjection::Unproject(const WorldCoordinates& world_point,
6260
GeoCoordinates3d& geo_point) const {
63-
geo_point = toGeodetic(world_point);
61+
geo_point = ToGeoCoordinates(world_point);
6462
return true;
6563
}
6664

olp-cpp-sdk-core/src/geo/projection/SphereProjection.cpp

Lines changed: 28 additions & 31 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.
@@ -17,46 +17,43 @@
1717
* License-Filename: LICENSE
1818
*/
1919

20-
#include <olp/core/geo/projection/SphereProjection.h>
20+
#include "olp/core/geo/projection/SphereProjection.h"
2121

22-
#include <olp/core/geo/coordinates/GeoCoordinates.h>
23-
#include <olp/core/geo/coordinates/GeoCoordinates3d.h>
24-
#include <olp/core/geo/coordinates/GeoRectangle.h>
25-
#include <olp/core/geo/projection/EarthConstants.h>
26-
#include <olp/core/math/AlignedBox.h>
27-
#include <olp/core/math/Math.h>
22+
#include "olp/core/geo/Types.h"
23+
#include "olp/core/geo/coordinates/GeoCoordinates.h"
24+
#include "olp/core/geo/coordinates/GeoCoordinates3d.h"
25+
#include "olp/core/geo/coordinates/GeoRectangle.h"
26+
#include "olp/core/geo/projection/EarthConstants.h"
27+
#include "olp/core/math/AlignedBox.h"
28+
#include "olp/core/math/Math.h"
2829

2930
namespace olp {
30-
31-
using namespace math;
32-
3331
namespace geo {
3432
namespace {
35-
36-
static Vector3d worldNormal(const GeoCoordinates& geo_point) {
37-
const double cosLatitude = cos(geo_point.GetLatitude());
38-
return Vector3d(cos(geo_point.GetLongitude()) * cosLatitude,
39-
sin(geo_point.GetLongitude()) * cosLatitude,
40-
sin(geo_point.GetLatitude()));
33+
static WorldCoordinates WorldNormal(const GeoCoordinates& geo_coordinates) {
34+
const double cos_latitude = cos(geo_coordinates.GetLatitude());
35+
return {cos(geo_coordinates.GetLongitude()) * cos_latitude,
36+
sin(geo_coordinates.GetLongitude()) * cos_latitude,
37+
sin(geo_coordinates.GetLatitude())};
4138
}
4239

43-
Vector3d toWorld(const GeoCoordinates3d& geo_coords) {
40+
WorldCoordinates ToWorldCoordinates(const GeoCoordinates3d& geo_coordinates) {
4441
const double radius =
45-
EarthConstants::EquatorialRadius() + geo_coords.GetAltitude();
46-
return worldNormal(geo_coords.GetGeoCoordinates()) * radius;
42+
EarthConstants::EquatorialRadius() + geo_coordinates.GetAltitude();
43+
return WorldNormal(geo_coordinates.GetGeoCoordinates()) * radius;
4744
}
4845

49-
GeoCoordinates3d toGeodetic(const Vector3d& point) {
50-
const double parallelRadiusSq = point.x * point.x + point.y * point.y;
51-
const double parallelRadius = sqrt(parallelRadiusSq);
46+
GeoCoordinates3d ToGeoCoordinates(const WorldCoordinates& point) {
47+
const double parallel_radius_square = point.x * point.x + point.y * point.y;
48+
const double parallel_radius = sqrt(parallel_radius_square);
5249

5350
// World-space origin maps to any lat, lng
54-
const double v = point.z / parallelRadius;
55-
if (isnan(v)) {
51+
const double v = point.z / parallel_radius;
52+
if (math::isnan(v)) {
5653
return {0, 0, -EarthConstants::EquatorialRadius()};
5754
}
5855

59-
const double radius = sqrt(parallelRadiusSq + point.z * point.z);
56+
const double radius = sqrt(parallel_radius_square + point.z * point.z);
6057

6158
return {atan(v), atan2(point.y, point.x),
6259
radius - EarthConstants::EquatorialRadius()};
@@ -65,25 +62,25 @@ GeoCoordinates3d toGeodetic(const Vector3d& point) {
6562
} // namespace
6663

6764
GeoRectangle SphereProjection::GetGeoBounds() const {
68-
return {{-half_pi, -pi}, {+half_pi, +pi}};
65+
return {{-math::half_pi, -math::pi}, {+math::half_pi, +math::pi}};
6966
}
7067

71-
WorldAlignedBox SphereProjection::WorldExtent(double /*minimum_altitude*/,
68+
WorldAlignedBox SphereProjection::WorldExtent(double,
7269
double maximum_altitude) const {
73-
auto radius = Vector3d(1, 1, 1) *
70+
auto radius = WorldCoordinates(1, 1, 1) *
7471
(EarthConstants::EquatorialRadius() + maximum_altitude);
7572
return WorldAlignedBox(-radius, radius);
7673
}
7774

7875
bool SphereProjection::Project(const GeoCoordinates3d& geo_point,
7976
WorldCoordinates& world_point) const {
80-
world_point = toWorld(geo_point);
77+
world_point = ToWorldCoordinates(geo_point);
8178
return true;
8279
}
8380

8481
bool SphereProjection::Unproject(const WorldCoordinates& world_point,
8582
GeoCoordinates3d& geo_point) const {
86-
geo_point = toGeodetic(world_point);
83+
geo_point = ToGeoCoordinates(world_point);
8784
return true;
8885
}
8986

0 commit comments

Comments
 (0)