| 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 |
#include "atlas/domain/Domain.h" |
| 12 |
#include "atlas/domain/detail/Domain.h" |
| 13 |
#include "atlas/domain/detail/EmptyDomain.h" |
| 14 |
#include "atlas/domain/detail/GlobalDomain.h" |
| 15 |
#include "atlas/domain/detail/RectangularDomain.h" |
| 16 |
#include "atlas/domain/detail/ZonalBandDomain.h" |
| 17 |
|
| 18 |
using RD = atlas::domain::RectangularDomain; |
| 19 |
using ZD = atlas::domain::ZonalBandDomain; |
| 20 |
|
| 21 |
namespace atlas { |
| 22 |
|
| 23 |
Domain::Domain(const eckit::Parametrisation& p): Handle(atlas::domain::Domain::create(p)) {} |
| 24 |
|
| 25 |
RectangularDomain::RectangularDomain(const Interval& x, const Interval& y, const std::string& units): |
| 26 |
Domain((RD::is_global(x, y, units)) |
| 27 |
? new atlas::domain::GlobalDomain(x[0]) |
| 28 |
: (RD::is_zonal_band(x, units) ? new atlas::domain::ZonalBandDomain(y, x[0]) |
| 29 |
: new atlas::domain::RectangularDomain(x, y, units))), |
| 30 |
domain_(dynamic_cast<const atlas::domain::RectangularDomain*>(get())) {} |
| 31 |
|
| 32 |
RectangularDomain::RectangularDomain(const Domain& domain): |
| 33 |
Domain(domain), domain_(dynamic_cast<const atlas::domain::RectangularDomain*>(get())) {} |
| 34 |
|
| 35 |
bool RectangularDomain::contains_x(double x) const { |
| 36 |
return domain_->contains_x(x); |
| 37 |
} |
| 38 |
|
| 39 |
bool RectangularDomain::contains_y(double y) const { |
| 40 |
return domain_->contains_y(y); |
| 41 |
} |
| 42 |
|
| 43 |
bool RectangularDomain::zonal_band() const { |
| 44 |
return domain_->zonal_band(); |
| 45 |
} |
| 46 |
|
| 47 |
double RectangularDomain::xmin() const { |
| 48 |
return domain_->xmin(); |
| 49 |
} |
| 50 |
|
| 51 |
double RectangularDomain::xmax() const { |
| 52 |
return domain_->xmax(); |
| 53 |
} |
| 54 |
|
| 55 |
double RectangularDomain::ymin() const { |
| 56 |
return domain_->ymin(); |
| 57 |
} |
| 58 |
|
| 59 |
double RectangularDomain::ymax() const { |
| 60 |
return domain_->ymax(); |
| 61 |
} |
| 62 |
|
| 63 |
ZonalBandDomain::ZonalBandDomain(const Interval& y): |
| 64 |
RectangularLonLatDomain((ZD::is_global(y)) ? new atlas::domain::GlobalDomain() |
| 65 |
: new atlas::domain::ZonalBandDomain(y)), |
| 66 |
domain_(dynamic_cast<const atlas::domain::ZonalBandDomain*>(get())) {} |
| 67 |
|
| 68 |
ZonalBandDomain::ZonalBandDomain(const Interval& y, const double& west): |
| 69 |
RectangularLonLatDomain((ZD::is_global(y)) ? new atlas::domain::GlobalDomain(west) |
| 70 |
: new atlas::domain::ZonalBandDomain(y, west)), |
| 71 |
domain_(dynamic_cast<const atlas::domain::ZonalBandDomain*>(get())) {} |
| 72 |
|
| 73 |
ZonalBandDomain::ZonalBandDomain(const Domain& domain): |
| 74 |
RectangularLonLatDomain(domain), domain_(dynamic_cast<const atlas::domain::ZonalBandDomain*>(get())) {} |
| 75 |
|
| 76 |
GlobalDomain::GlobalDomain(const double& west): |
| 77 |
ZonalBandDomain(new atlas::domain::GlobalDomain(west)), |
| 78 |
domain_(dynamic_cast<const atlas::domain::GlobalDomain*>(get())) {} |
| 79 |
|
| 80 |
GlobalDomain::GlobalDomain(): |
| 81 |
ZonalBandDomain(new atlas::domain::GlobalDomain()), |
| 82 |
domain_(dynamic_cast<const atlas::domain::GlobalDomain*>(get())) {} |
| 83 |
|
| 84 |
GlobalDomain::GlobalDomain(const Domain& domain): |
| 85 |
ZonalBandDomain(domain), domain_(dynamic_cast<const atlas::domain::GlobalDomain*>(get())) {} |
| 86 |
|
| 87 |
|
| 88 |
std::string atlas::Domain::type() const { |
| 89 |
return get()->type(); |
| 90 |
} |
| 91 |
|
| 92 |
bool Domain::contains(double x, double y) const { |
| 93 |
return get()->contains(x, y); |
| 94 |
} |
| 95 |
|
| 96 |
bool Domain::contains(const PointXY& p) const { |
| 97 |
return get()->contains(p); |
| 98 |
} |
| 99 |
|
| 100 |
std::string Domain::units() const { |
| 101 |
return get()->units(); |
| 102 |
} |
| 103 |
|
| 104 |
Domain::Spec Domain::spec() const { |
| 105 |
return get()->spec(); |
| 106 |
} |
| 107 |
|
| 108 |
bool Domain::global() const { |
| 109 |
return get()->global(); |
| 110 |
} |
| 111 |
|
| 112 |
bool Domain::empty() const { |
| 113 |
return get()->empty(); |
| 114 |
} |
| 115 |
|
| 116 |
void Domain::hash(eckit::Hash& h) const { |
| 117 |
get()->hash(h); |
| 118 |
} |
| 119 |
|
| 120 |
bool Domain::containsNorthPole() const { |
| 121 |
return get()->containsNorthPole(); |
| 122 |
} |
| 123 |
|
| 124 |
bool Domain::containsSouthPole() const { |
| 125 |
return get()->containsSouthPole(); |
| 126 |
} |
| 127 |
|
| 128 |
void Domain::print(std::ostream& os) const { |
| 129 |
get()->print(os); |
| 130 |
} |
| 131 |
|
| 132 |
std::ostream& operator<<(std::ostream& os, const Domain& d) { |
| 133 |
d.print(os); |
| 134 |
return os; |
| 135 |
} |
| 136 |
|
| 137 |
} // namespace atlas |