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

Enable latitude normalisation in KDTree coordinate transform #140

Merged
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
17 changes: 17 additions & 0 deletions src/atlas/util/Geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,28 @@
#include "eckit/geometry/Point2.h"
#include "eckit/geometry/Point3.h"

#include "atlas/library/config.h"
#include "atlas/runtime/Exception.h"
#include "atlas/util/Geometry.h"

namespace atlas {

namespace geometry {
namespace detail {
void GeometrySphere::lonlat2xyz(const Point2& lonlat, Point3& xyz) const {
#if ATLAS_ECKIT_VERSION_AT_LEAST(1, 24, 0)
Sphere::convertSphericalToCartesian(radius_, lonlat, xyz, 0., true);
#else
Sphere::convertSphericalToCartesian(radius_, lonlat, xyz);
#endif
}
void GeometrySphere::xyz2lonlat(const Point3& xyz, Point2& lonlat) const {
Sphere::convertCartesianToSpherical(radius_, xyz, lonlat);
}

} // namespace detail
} // namespace geometry

extern "C" {
// ------------------------------------------------------------------
// C wrapper interfaces to C++ routines
Expand Down
8 changes: 2 additions & 6 deletions src/atlas/util/Geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,8 @@ class GeometrySphere : public GeometryBase {

public:
GeometrySphere(double radius): radius_(radius) {}
void lonlat2xyz(const Point2& lonlat, Point3& xyz) const override {
Sphere::convertSphericalToCartesian(radius_, lonlat, xyz);
}
void xyz2lonlat(const Point3& xyz, Point2& lonlat) const override {
Sphere::convertCartesianToSpherical(radius_, xyz, lonlat);
}
void lonlat2xyz(const Point2& lonlat, Point3& xyz) const override;
void xyz2lonlat(const Point3& xyz, Point2& lonlat) const override;
double distance(const Point2& p1, const Point2& p2) const override { return Sphere::distance(radius_, p1, p2); }
double distance(const Point3& p1, const Point3& p2) const override { return Sphere::distance(radius_, p1, p2); }
double radius() const override { return radius_; }
Expand Down