Debian Codegraph @

src/atlas/grid/detail/tiles/Tiles.cc

raw
1 /*
2 * (C) Crown Copyright 2021 Met Office.
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 <string>
12
13 #include "eckit/utils/MD5.h"
14
15 #include "atlas/grid/detail/tiles/Tiles.h"
16 #include "atlas/grid/detail/tiles/TilesFactory.h"
17 #include "atlas/runtime/Exception.h"
18 #include "atlas/util/Config.h"
19
20 namespace atlas {
21 namespace grid {
22 namespace detail {
23
24 const CubedSphereTiles* CubedSphereTiles::create() {
25 // default: LFRic version (for now)
26 util::Config params;
27 params.set("type", "cubedsphere_lfric");
28 return CubedSphereTiles::create(params);
29 }
30
31 const CubedSphereTiles* CubedSphereTiles::create(const std::string& s) {
32 util::Config params;
33 if (s == "") {
34 return CubedSphereTiles::create();
35 }
36 params.set("type", s);
37 return CubedSphereTiles::create(params);
38 }
39
40 const CubedSphereTiles* CubedSphereTiles::create(const eckit::Parametrisation& p) {
41 std::string CubedSphereTiles_type;
42
43 if (p.has("type")) {
44 p.get("type", CubedSphereTiles_type);
45 return CubedSphereTilesFactory::build(CubedSphereTiles_type, p);
46 }
47 else {
48 return create();
49 }
50 }
51
52 idx_t CubedSphereTiles::indexFromXY(const PointXY& xy) const {
53 return indexFromXY(xy.data());
54 }
55
56 idx_t CubedSphereTiles::indexFromLonLat(const PointLonLat& lonlat) const {
57 return indexFromXY(lonlat.data());
58 }
59
60 } // namespace detail
61 } // namespace grid
62 } // namespace atlas