17 #include "atlas/runtime/Exception.h" 18 #include "atlas/util/Earth.h" 19 #include "atlas/util/Object.h" 20 #include "atlas/util/ObjectHandle.h" 33 virtual void lonlat2xyz(
const Point2&, Point3& )
const = 0;
34 virtual void xyz2lonlat(
const Point3&, Point2& )
const = 0;
35 virtual double distance(
const Point2& p1,
const Point2& p2 )
const = 0;
36 virtual double distance(
const Point3& p1,
const Point3& p2 )
const = 0;
37 virtual double radius()
const = 0;
38 virtual double area()
const = 0;
40 Point3 xyz(
const Point2& lonlat )
const {
42 lonlat2xyz( lonlat, xyz );
45 Point2 lonlat(
const Point3& xyz )
const {
47 xyz2lonlat( xyz, lonlat );
54 template <
typename SphereT>
57 void lonlat2xyz(
const Point2& lonlat, Point3& xyz )
const override {
58 SphereT::convertSphericalToCartesian( lonlat, xyz );
60 void xyz2lonlat(
const Point3& xyz, Point2& lonlat )
const override {
61 SphereT::convertCartesianToSpherical( xyz, lonlat );
63 double distance(
const Point2& p1,
const Point2& p2 )
const override {
return SphereT::distance( p1, p2 ); }
64 double distance(
const Point3& p1,
const Point3& p2 )
const override {
return SphereT::distance( p1, p2 ); }
65 double radius()
const override {
return SphereT::radius(); }
66 double area()
const override {
return SphereT::area(); }
70 using Sphere = eckit::geometry::Sphere;
74 void lonlat2xyz(
const Point2& lonlat, Point3& xyz )
const override {
75 Sphere::convertSphericalToCartesian( radius_, lonlat, xyz );
77 void xyz2lonlat(
const Point3& xyz, Point2& lonlat )
const override {
78 Sphere::convertCartesianToSpherical( radius_, xyz, lonlat );
80 double distance(
const Point2& p1,
const Point2& p2 )
const override {
return Sphere::distance( radius_, p1, p2 ); }
81 double distance(
const Point3& p1,
const Point3& p2 )
const override {
return Sphere::distance( radius_, p1, p2 ); }
82 double radius()
const override {
return radius_; }
83 double area()
const override {
return Sphere::area( radius_ ); }
99 Geometry(
const std::string& name ) : Handle( build( name ) ) {}
100 Geometry(
const char* name ) : Handle( build( name ) ) {}
101 Geometry(
double radius ) : Handle( build<geometry::detail::GeometrySphere>( radius ) ) {}
103 template <
typename SphereT>
104 Geometry(
const SphereT& ) : Handle( build<SphereT>() ) {}
106 Point3 xyz(
const Point2& lonlat )
const {
return get()->xyz( lonlat ); }
107 Point2 lonlat(
const Point3& xyz )
const {
return get()->lonlat( xyz ); }
108 void xyz2lonlat(
const Point3& xyz, Point2& lonlat )
const {
get()->xyz2lonlat( xyz, lonlat ); }
109 void lonlat2xyz(
const Point2& lonlat, Point3& xyz )
const {
get()->lonlat2xyz( lonlat, xyz ); }
110 double distance(
const Point2& p1,
const Point2& p2 )
const {
return get()->distance( p1, p2 ); }
111 double distance(
const Point3& p1,
const Point3& p2 )
const {
return get()->distance( p1, p2 ); }
112 double radius()
const {
return get()->radius(); }
113 double area()
const {
return get()->area(); }
116 template <
typename GeometryT,
typename... Args>
118 return new GeometryT( args... );
123 if ( name ==
"Earth" ) {
124 return build<geometry::detail::GeometrySphereT<util::Earth>>();
126 else if ( name ==
"UnitSphere" ) {
127 return build<geometry::detail::GeometrySphereT<eckit::geometry::UnitSphere>>();
130 ATLAS_THROW_EXCEPTION(
"name " << name <<
" is not a valid key for a Geometry" );
155 double& lon,
double& lat );
157 double& y,
double& z );
159 const double lon2,
const double lat2 );
160 double atlas__Geometry__distance_xyz(
Geometry::Implementation* This,
const double x1,
const double y1,
const double z1,
161 const double x2,
const double y2,
const double z2 );
Definition: Geometry.h:94
This file contains classes and functions working on points.
Definition: Geometry.h:30
Definition: Geometry.h:139
Definition: Geometry.h:55
Definition: Geometry.h:69
Contains all atlas classes and methods.
Definition: atlas-grids.cc:33
Definition: ObjectHandle.h:64