Debian Codegraph @

src/atlas/projection/detail/MercatorProjection.h

raw
1 /*
2 * (C) Copyright 2013 ECMWF.
3 *
4 * This software is licensed under the terms of the Apache Licence Version 2.0
5 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6 * In applying this licence, ECMWF does not waive the privileges and immunities
7 * granted to it by virtue of its status as an intergovernmental organisation
8 * nor does it submit to any jurisdiction.
9 */
10
11 #pragma once
12
13 #include "atlas/domain.h"
14 #include "atlas/projection/detail/ProjectionImpl.h"
15 #include "atlas/util/NormaliseLongitude.h"
16
17 namespace atlas {
18 namespace projection {
19 namespace detail {
20
21 template <typename Rotation>
22 class MercatorProjectionT final : public ProjectionImpl {
23 public:
24 // constructor
25 MercatorProjectionT(const eckit::Parametrisation&);
26
27 // projection name
28 static std::string static_type() { return Rotation::typePrefix() + "mercator"; }
29 std::string type() const override { return static_type(); }
30
31 // projection and inverse projection
32 void xy2lonlat(double crd[]) const override;
33 void lonlat2xy(double crd[]) const override;
34
35 Jacobian jacobian(const PointLonLat&) const override;
36
37 bool strictlyRegional() const override { return true; } // Mercator projection cannot be used for global grids
38 RectangularLonLatDomain lonlatBoundingBox(const Domain& domain) const override {
39 return ProjectionImpl::lonlatBoundingBox(domain);
40 }
41
42 // specification
43 Spec spec() const override;
44
45 std::string units() const override { return "meters"; }
46
47 void hash(eckit::Hash&) const override;
48
49 protected:
50 Normalise normalise_;
51 util::NormaliseLongitude normalise_mercator_;
52 double lon0_; // central longitude (default = 0 )
53 double lat1_; // latitude where cylinder cuts sphere (default = 0 )
54 double radius_; // sphere radius
55 double k_radius_; // sphere radius
56 double inv_k_radius_; // 1/(sphere radius)
57
58 double eccentricity_;
59 double semi_major_axis_;
60 double semi_minor_axis_;
61
62 double false_easting_;
63 double false_northing_;
64
65
66 void setup(const eckit::Parametrisation& p);
67
68 private:
69 Rotation rotation_;
70 };
71
72 using MercatorProjection = MercatorProjectionT<NotRotated>;
73 using RotatedMercatorProjection = MercatorProjectionT<Rotated>;
74
75 } // namespace detail
76 } // namespace projection
77 } // namespace atlas