Skip to content

Commit

Permalink
eckit::geo
Browse files Browse the repository at this point in the history
  • Loading branch information
pmaciel committed Aug 27, 2023
1 parent fec659c commit 7205113
Show file tree
Hide file tree
Showing 146 changed files with 4,367 additions and 958 deletions.
29 changes: 17 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,24 @@ ecbuild_add_option( FEATURE AEC
ecbuild_add_option( FEATURE XXHASH
DESCRIPTION "xxHash support for hashing" )

### Codec options

set( eckit_CODEC_RECORD_BEGIN "ATLAS-IO" CACHE STRING "eckit::codec record begin" )
set( eckit_CODEC_RECORD_END "ATLAS-IO-END" CACHE STRING "eckit::codec record end" )
# also ECKIT_CODEC_STATIC_ASSERT

### Geometry options

ecbuild_add_option( FEATURE GEOMETRY_CACHING
DEFAULT OFF
DESCRIPTION "eckit::geometry default caching behaviour" )
if ( HAVE_EXPERIMENTAL )
### eckit::codec options

set( eckit_CODEC_RECORD_BEGIN "ATLAS-IO" CACHE STRING "eckit::codec record begin" )
set( eckit_CODEC_RECORD_END "ATLAS-IO-END" CACHE STRING "eckit::codec record end" )
# also ECKIT_CODEC_STATIC_ASSERT
endif()

set( eckit_GEOMETRY_CACHE_PATH "/tmp/cache" )
if ( HAVE_EXPERIMENTAL )
### eckit::geo options

ecbuild_add_option( FEATURE GEO_CACHING
CONDITION HAVE_EXPERIMENTAL
DEFAULT OFF
DESCRIPTION "eckit::geo default caching behaviour" )

set( eckit_GEO_CACHE_PATH "/tmp/cache" )
endif()

### LAPACK

Expand Down
2 changes: 1 addition & 1 deletion etc/eckit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
add_subdirectory(geometry)
add_subdirectory(geo)

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
file(GLOB _files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.yaml")
set(_destination "etc/eckit/geometry")
set(_destination "etc/eckit/geo")

install(FILES ${_files} DESTINATION ${_destination} PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)

Expand Down
File renamed without changes.
24 changes: 17 additions & 7 deletions src/eckit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -347,17 +347,13 @@ config/Configuration.cc
config/Configuration.h
config/Configured.cc
config/Configured.h
config/DynamicConfiguration.cc
config/DynamicConfiguration.h
config/EtcTable.cc
config/EtcTable.h
config/JSONConfiguration.h
config/LibEcKit.cc
config/LibEcKit.h
config/LocalConfiguration.cc
config/LocalConfiguration.h
config/MappedConfiguration.cc
config/MappedConfiguration.h
config/Parametrisation.cc
config/Parametrisation.h
config/Resource.h
Expand All @@ -369,6 +365,15 @@ config/YAMLConfiguration.cc
config/YAMLConfiguration.h
)

if( HAVE_EXPERIMENTAL )
list( APPEND eckit_config_srcs
config/DynamicConfiguration.cc
config/DynamicConfiguration.h
config/MappedConfiguration.cc
config/MappedConfiguration.h
)
endif()

list( APPEND eckit_runtime_srcs
runtime/Application.cc
runtime/Application.h
Expand Down Expand Up @@ -963,18 +968,23 @@ ecbuild_add_library(
### sub-directories

if( HAVE_ECKIT_CMD )
add_subdirectory( cmd )
add_subdirectory( cmd )
endif()

if( HAVE_ECKIT_SQL )
add_subdirectory( sql )
add_subdirectory( sql )
endif()

add_subdirectory( codec )
add_subdirectory( distributed )
add_subdirectory( geometry )
add_subdirectory( linalg )
add_subdirectory( maths )
add_subdirectory( mpi )
add_subdirectory( option )
add_subdirectory( web )

if( HAVE_EXPERIMENTAL )
add_subdirectory( codec )
add_subdirectory( geo )
endif()

4 changes: 2 additions & 2 deletions src/eckit/geometry/Area.h → src/eckit/geo/Area.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Configuration;
}


namespace eckit::geometry {
namespace eckit::geo {


class Area {
Expand Down Expand Up @@ -110,4 +110,4 @@ class Area {
// using AreaBuilder = ConcreteBuilderT1<Area, T>;


} // namespace eckit::geometry
} // namespace eckit::geo
130 changes: 130 additions & 0 deletions src/eckit/geo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@

configure_file( eckit_geo_config.h.in eckit_geo_config.h @ONLY )
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/eckit_geo_config.h
DESTINATION ${INSTALL_INCLUDE_DIR}/eckit
)

list( APPEND eckit_geo_srcs
${CMAKE_CURRENT_BINARY_DIR}/eckit_geo_config.h
Area.h
Cache.cc
Cache.h
Configurator.h
CoordinateHelpers.cc
CoordinateHelpers.h
Domain.cc
Domain.h
Earth.h
EllipsoidOfRevolution.cc
EllipsoidOfRevolution.h
Figure.h
GreatCircle.cc
GreatCircle.h
Grid.cc
Grid.h
GridConfig.cc
GridConfig.h
Iterator.h
KPoint.cc
KPoint.h
LibEcKitGeo.cc
LibEcKitGeo.h
Ordering.h
Point.cc
Point.h
Point2.cc
Point2.h
Point3.cc
Point3.h
PointLonLat.cc
PointLonLat.h
Projection.h
Range.cc
Range.h
Renumber.h
Search.h
Sphere.cc
Sphere.h
SphereT.h
UnitSphere.h
area/BoundingBox.cc
area/BoundingBox.h
grid/Reduced.cc
grid/Reduced.h
grid/Regular.cc
grid/Regular.h
grid/Unstructured.cc
grid/Unstructured.h
grid/reduced/HEALPix.cc
grid/reduced/HEALPix.h
grid/reduced/ReducedGaussian.cc
grid/reduced/ReducedGaussian.h
grid/reduced/ReducedLatLon.cc
grid/reduced/ReducedLatLon.h
grid/regular/IrregularLatLon.cc
grid/regular/IrregularLatLon.h
grid/regular/RegularGaussian.cc
grid/regular/RegularGaussian.h
grid/regular/RegularLatLon.cc
grid/regular/RegularLatLon.h
grid/unstructured/ORCA.cc
grid/unstructured/ORCA.h
iterator/Reduced.cc
iterator/Reduced.h
iterator/Regular.cc
iterator/Regular.h
iterator/Unstructured.cc
iterator/Unstructured.h
polygon/LonLatPolygon.cc
polygon/LonLatPolygon.h
polygon/Polygon.cc
polygon/Polygon.h
projection/LonLatToXYZ.cc
projection/LonLatToXYZ.h
projection/None.cc
projection/None.h
projection/Rotation.cc
projection/Rotation.h
range/Gaussian.cc
range/Gaussian.h
range/GlobalRegular.cc
range/GlobalRegular.h
range/LocalRegular.cc
range/LocalRegular.h
util.cc
util.h
util/arange.cc
util/gaussian_latitudes.cc
util/linspace.cc
util/monotonic_crop.cc
util/reduced_classical_pl.cc
util/reduced_octahedral_pl.cc
util/regex.cc
util/regex.h
)

set(eckit_geo_include_dirs
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/src>
)

set(eckit_geo_libs eckit_maths eckit_codec)

if(HAVE_PROJ)
list(APPEND eckit_geo_srcs projection/PROJ.cc projection/PROJ.h)
list(APPEND eckit_geo_libs PROJ::proj)
list(APPEND eckit_geo_include_dirs ${PROJ_INCLUDE_DIRS})
endif()

ecbuild_add_library(
TARGET eckit_geo
TYPE SHARED

INSTALL_HEADERS ALL
HEADER_DESTINATION ${INSTALL_INCLUDE_DIR}/eckit/geo
PUBLIC_LIBS ${eckit_geo_libs}
PUBLIC_INCLUDES ${eckit_geo_include_dirs}

SOURCES ${eckit_geo_srcs}
)
6 changes: 3 additions & 3 deletions src/eckit/geometry/Cache.cc → src/eckit/geo/Cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
*/


#include "eckit/geometry/Cache.h"
#include "eckit/geo/Cache.h"


#include <map>
#include <memory>
#include <utility>


namespace eckit::geometry::cache {
namespace eckit::geo::cache {


static std::map<std::string, std::unique_ptr<Cache>> __cache;
Expand All @@ -44,4 +44,4 @@ void test() {
}


} // namespace eckit::geometry::cache
} // namespace eckit::geo::cache
4 changes: 2 additions & 2 deletions src/eckit/geometry/Cache.h → src/eckit/geo/Cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <type_traits>


namespace eckit::geometry::cache {
namespace eckit::geo::cache {


class Cache {
Expand Down Expand Up @@ -52,4 +52,4 @@ class CacheableT : public Cache {
};


} // namespace eckit::geometry::cache
} // namespace eckit::geo::cache
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Configuration;
}


namespace eckit::geometry {
namespace eckit::geo {

//------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -342,4 +342,4 @@ class ConcreteConfigurationGeneratorT2 final : public ConfigurationGeneratorT2<A

//------------------------------------------------------------------------------------------------------

} // namespace eckit::geometry
} // namespace eckit::geo
55 changes: 55 additions & 0 deletions src/eckit/geo/CoordinateHelpers.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* (C) Copyright 2023 UCAR
*
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
*/

#include <limits>
#include <sstream>

#include "eckit/exception/Exceptions.h"
#include "eckit/geo/CoordinateHelpers.h"
#include "eckit/geo/Point2.h"

namespace eckit::geo {

//----------------------------------------------------------------------------------------------------------------------

double normalise_angle(double a, const double minimum) {
while (a < minimum) {
a += 360.;
}
while (a >= minimum + 360.) {
a -= 360.;
}
return a;
}

//----------------------------------------------------------------------------------------------------------------------

Point2 canonicaliseOnSphere(const Point2& lonlat, const double minimum_lon) {
const double lat = normalise_angle(lonlat[1], -90.);
const bool across_pole = (lat > 90.);

if (!across_pole) {
return {normalise_angle(lonlat[0], minimum_lon), lat};
}

return {normalise_angle(lonlat[0] + 180., minimum_lon), 180. - lat};
}

//----------------------------------------------------------------------------------------------------------------------

void assert_latitude_range(double lat) {
if (!(-90. <= lat && lat <= 90.)) {
std::ostringstream oss;
oss.precision(std::numeric_limits<double>::max_digits10);
oss << "Invalid latitude " << lat;
throw BadValue(oss.str(), Here());
}
}

//----------------------------------------------------------------------------------------------------------------------

} // namespace eckit::geo
Loading

0 comments on commit 7205113

Please sign in to comment.