| 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/grid/Grid.h" |
| 12 |
|
| 13 |
#include <limits> |
| 14 |
#include <string> |
| 15 |
#include <vector> |
| 16 |
|
| 17 |
#include "atlas/domain/Domain.h" |
| 18 |
#include "atlas/grid/Grid.h" |
| 19 |
#include "atlas/grid/Iterator.h" |
| 20 |
#include "atlas/grid/Spacing.h" |
| 21 |
#include "atlas/projection/Projection.h" |
| 22 |
#include "atlas/runtime/Exception.h" |
| 23 |
#include "atlas/util/Config.h" |
| 24 |
|
| 25 |
namespace atlas { |
| 26 |
|
| 27 |
Grid::IterateXY Grid::xy() const { |
| 28 |
return Grid::IterateXY(*get()); |
| 29 |
} |
| 30 |
|
| 31 |
Grid::IterateLonLat Grid::lonlat() const { |
| 32 |
return Grid::IterateLonLat(*get()); |
| 33 |
} |
| 34 |
|
| 35 |
Grid::Grid(const std::string& shortname, const Domain& domain): |
| 36 |
Handle([&] { |
| 37 |
Config config; |
| 38 |
if (domain) { |
| 39 |
config.set("domain", domain.spec()); |
| 40 |
} |
| 41 |
return Grid::Implementation::create(shortname, config); |
| 42 |
}()) {} |
| 43 |
|
| 44 |
Grid::Grid(const std::string& shortname, const Projection& projection, const Domain& domain): |
| 45 |
Handle([&] { |
| 46 |
Config config; |
| 47 |
if (projection) { |
| 48 |
config.set("projection", projection.spec()); |
| 49 |
} |
| 50 |
if (domain) { |
| 51 |
config.set("domain", domain.spec()); |
| 52 |
} |
| 53 |
return Grid::Implementation::create(shortname, config); |
| 54 |
}()) {} |
| 55 |
|
| 56 |
Grid::Grid(const Grid& grid, const Grid::Domain& domain): |
| 57 |
Handle([&] { |
| 58 |
ATLAS_ASSERT(grid); |
| 59 |
return Grid::Implementation::create(*grid.get(), domain); |
| 60 |
}()) {} |
| 61 |
|
| 62 |
Grid::Grid(const Config& p): Handle(Grid::Implementation::create(p)) {} |
| 63 |
|
| 64 |
idx_t Grid::size() const { |
| 65 |
return get()->size(); |
| 66 |
} |
| 67 |
|
| 68 |
size_t Grid::footprint() const { |
| 69 |
return get()->footprint(); |
| 70 |
} |
| 71 |
|
| 72 |
const Grid::Projection& Grid::projection() const { |
| 73 |
return get()->projection(); |
| 74 |
} |
| 75 |
|
| 76 |
const Grid::Domain& Grid::domain() const { |
| 77 |
return get()->domain(); |
| 78 |
} |
| 79 |
|
| 80 |
RectangularLonLatDomain Grid::lonlatBoundingBox() const { |
| 81 |
return get()->lonlatBoundingBox(); |
| 82 |
} |
| 83 |
|
| 84 |
std::string Grid::name() const { |
| 85 |
return get()->name(); |
| 86 |
} |
| 87 |
|
| 88 |
std::string Grid::type() const { |
| 89 |
return get()->type(); |
| 90 |
} |
| 91 |
|
| 92 |
std::string Grid::uid() const { |
| 93 |
return get()->uid(); |
| 94 |
} |
| 95 |
|
| 96 |
void Grid::hash(eckit::Hash& h) const { |
| 97 |
get()->hash(h); |
| 98 |
} |
| 99 |
|
| 100 |
Grid::Spec Grid::spec() const { |
| 101 |
return get()->spec(); |
| 102 |
} |
| 103 |
|
| 104 |
Grid::Config Grid::meshgenerator() const { |
| 105 |
return get()->meshgenerator(); |
| 106 |
} |
| 107 |
|
| 108 |
Grid::Config Grid::partitioner() const { |
| 109 |
return get()->partitioner(); |
| 110 |
} |
| 111 |
|
| 112 |
} // namespace atlas |