diff --git a/include/geopackage/proj.hpp b/include/geopackage/proj.hpp index e287fd15de..934671b06c 100644 --- a/include/geopackage/proj.hpp +++ b/include/geopackage/proj.hpp @@ -2,6 +2,7 @@ #define NGEN_GEOPACKAGE_PROJ_HPP #include +#include namespace ngen { namespace srs { @@ -21,8 +22,8 @@ struct epsg static srs_type get(uint32_t srid); private: - static const srs_type epsg5070_; - static const srs_type epsg3857_; + using def_type = std::unordered_map; + static const def_type defs_; }; } // namespace srs diff --git a/src/geopackage/CMakeLists.txt b/src/geopackage/CMakeLists.txt index e68894e87b..7786671af3 100644 --- a/src/geopackage/CMakeLists.txt +++ b/src/geopackage/CMakeLists.txt @@ -1,14 +1,3 @@ -string(COMPARE EQUAL "${CMAKE_CXX_COMPILER_ID}" "IntelLLVM" _cmp) -if (NOT _cmp) - message(WARNING "[NGen::geopackage] wkb.cpp cannot be optimized with " - "${CMAKE_CXX_COMPILER_ID} due to a suspected optimizer/boost issue:\n" - "https://github.com/NOAA-OWP/ngen/issues/567.\n" - "Use IntelLLVM if optimization for this source file is required.") - # !! Required due to optimizer issue with either clang or - # !! boost::geometry::srs::transformation - set_source_files_properties(wkb.cpp PROPERTIES COMPILE_OPTIONS "-O0;-fno-sanitize=all") -endif() - add_library(geopackage proj.cpp geometry.cpp properties.cpp diff --git a/src/geopackage/proj.cpp b/src/geopackage/proj.cpp index f8f28ba377..8bd5746d34 100644 --- a/src/geopackage/proj.cpp +++ b/src/geopackage/proj.cpp @@ -1,42 +1,22 @@ #include "proj.hpp" -#include namespace ngen { namespace srs { -const epsg::srs_type epsg::epsg5070_ = - epsg::srs_type(bg::srs::dpar::proj_aea) - (bg::srs::dpar::ellps_grs80) - (bg::srs::dpar::towgs84, {0,0,0,0,0,0,0}) - (bg::srs::dpar::lat_0, 23) - (bg::srs::dpar::lon_0, -96) - (bg::srs::dpar::lat_1, 29.5) - (bg::srs::dpar::lat_2, 45.5) - (bg::srs::dpar::x_0, 0) - (bg::srs::dpar::y_0, 0); - -const epsg::srs_type epsg::epsg3857_ = - epsg::srs_type(bg::srs::dpar::proj_merc) - (bg::srs::dpar::units_m) - (bg::srs::dpar::no_defs) - (bg::srs::dpar::a, 6378137) - (bg::srs::dpar::b, 6378137) - (bg::srs::dpar::lat_ts, 0) - (bg::srs::dpar::lon_0, 0) - (bg::srs::dpar::x_0, 0) - (bg::srs::dpar::y_0, 0) - (bg::srs::dpar::k, 1); +const epsg::def_type epsg::defs_ = { + {4326, epsg::srs_type(bg::srs::dpar::proj_longlat)(bg::srs::dpar::ellps_wgs84)(bg::srs::dpar::datum_wgs84)(bg::srs::dpar::no_defs)}, + {5070, epsg::srs_type(bg::srs::dpar::proj_aea)(bg::srs::dpar::ellps_grs80)(bg::srs::dpar::towgs84, {0,0,0,0,0,0,0})(bg::srs::dpar::lat_0, 23)(bg::srs::dpar::lon_0, -96)(bg::srs::dpar::lat_1, 29.5)(bg::srs::dpar::lat_2, 45.5)(bg::srs::dpar::x_0, 0)(bg::srs::dpar::y_0, 0)}, + {3857, epsg::srs_type(bg::srs::dpar::proj_merc)(bg::srs::dpar::units_m)(bg::srs::dpar::no_defs)(bg::srs::dpar::a, 6378137)(bg::srs::dpar::b, 6378137)(bg::srs::dpar::lat_ts, 0)(bg::srs::dpar::lon_0, 0)(bg::srs::dpar::x_0, 0)(bg::srs::dpar::y_0, 0)(bg::srs::dpar::k, 1)} +}; auto epsg::get(uint32_t srid) -> srs_type { - switch (srid) { - case 5070: - return epsg5070_; - case 3857: - return epsg3857_; - default: - return bg::projections::detail::epsg_to_parameters(srid); + + if (defs_.count(srid) == 0) { + throw std::runtime_error("SRID " + std::to_string(srid) + " is not supported. Project the input data to EPSG:5070 or EPSG:4326."); } + + return defs_.at(srid); } } // namespace srs