Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: Apply normalisation also to SphereT as was already done for unit-sphere #242

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/atlas/util/Geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ template <typename SphereT>
class GeometrySphereT : public GeometryBase {
public:
void lonlat2xyz(const Point2& lonlat, Point3& xyz) const override {
#if ATLAS_ECKIT_VERSION_AT_LEAST(1, 24, 0)
SphereT::convertSphericalToCartesian(lonlat, xyz, 0., true);
#else
SphereT::convertSphericalToCartesian(lonlat, xyz);
#endif
}
void xyz2lonlat(const Point3& xyz, Point2& lonlat) const override {
SphereT::convertCartesianToSpherical(xyz, lonlat);
Expand Down
6 changes: 6 additions & 0 deletions src/tests/AtlasTestEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ bool approx_eq(const Point2& v1, const Point2& v2) {
bool approx_eq(const Point2& v1, const Point2& v2, const double& t) {
return approx_eq(v1[0], v2[0], t) && approx_eq(v1[1], v2[1], t);
}
bool approx_eq(const Point3& v1, const Point3& v2) {
return approx_eq(v1[0], v2[0]) && approx_eq(v1[1], v2[1]) && approx_eq(v1[2], v2[2]);
}
bool approx_eq(const Point3& v1, const Point3& v2, const double& t) {
return approx_eq(v1[0], v2[0], t) && approx_eq(v1[1], v2[1], t) && approx_eq(v1[2], v2[2], t);
}

template <typename T1, typename T2>
std::string expect_message(const std::string& condition, const T1& lhs, const T2& rhs, const eckit::CodeLocation& loc) {
Expand Down
8 changes: 8 additions & 0 deletions src/tests/util/test_earth.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "atlas/util/Earth.h"
#include "atlas/util/Point.h"
#include "atlas/util/Geometry.h"

#include "tests/AtlasTestEnvironment.h"

Expand Down Expand Up @@ -169,6 +170,13 @@ CASE("test_earth_great_circle_latitude_given_longitude") {
EXPECT(eckit::types::is_approximately_equal(lat, -6.81, 0.01));
}

CASE("test_across_pole") {
const PointLonLat P1{-16.875,-105.255};
atlas::geometry::Earth geo;
EXPECT_APPROX_EQ(geo.xyz(P1), PointXYZ(-1.60418e+06,486624,-6.14673e+06), 50.);
}


} // namespace test
} // namespace atlas

Expand Down
Loading