diff --git a/src/command-line-parser.cpp b/src/command-line-parser.cpp index f5d96f059..568d9f5f5 100644 --- a/src/command-line-parser.cpp +++ b/src/command-line-parser.cpp @@ -14,6 +14,7 @@ #include "logging.hpp" #include "options.hpp" #include "pgsql.hpp" +#include "projection.hpp" #include "reprojection.hpp" #include "util.hpp" #include "version.hpp" @@ -244,7 +245,7 @@ void check_options_expire(options_t *options) { } if (options->expire_tiles_zoom != 0 && - options->projection->target_srs() != 3857) { + options->projection->target_srs() != PROJ_SPHERE_MERC) { log_warn("Expire has been enabled (with -e or --expire-tiles) but " "target SRS is not Mercator (EPSG:3857). Expire disabled!"); options->expire_tiles_zoom = 0; diff --git a/src/expire-tiles.cpp b/src/expire-tiles.cpp index 21eda2df7..d2325f9a1 100644 --- a/src/expire-tiles.cpp +++ b/src/expire-tiles.cpp @@ -28,6 +28,7 @@ #include "format.hpp" #include "geom-functions.hpp" #include "options.hpp" +#include "projection.hpp" #include "reprojection.hpp" #include "table.hpp" #include "tile.hpp" @@ -146,7 +147,7 @@ void expire_tiles::from_geometry(geom::geometry_t const &geom, void expire_tiles::from_geometry_if_3857(geom::geometry_t const &geom, expire_config_t const &expire_config) { - if (geom.srid() == 3857) { + if (geom.srid() == PROJ_SPHERE_MERC) { from_geometry(geom, expire_config); } } diff --git a/src/flex-lua-geom.cpp b/src/flex-lua-geom.cpp index ed48b5da3..4fc2880ee 100644 --- a/src/flex-lua-geom.cpp +++ b/src/flex-lua-geom.cpp @@ -12,6 +12,7 @@ #include "geom-functions.hpp" #include "geom-pole-of-inaccessibility.hpp" #include "lua-utils.hpp" +#include "projection.hpp" #include @@ -73,7 +74,7 @@ int geom_spherical_area(lua_State *lua_state) { auto const *const input_geometry = unpack_geometry(lua_state); - if (input_geometry->srid() != 4326) { + if (input_geometry->srid() != PROJ_LATLONG) { throw std::runtime_error{"Can only calculate spherical area for " "geometries in WGS84 (4326) coordinates."}; } @@ -282,7 +283,7 @@ int geom_transform(lua_State *lua_state) auto const srid = static_cast(luaL_checkinteger(lua_state, 2)); try { - if (input_geometry->srid() != 4326) { + if (input_geometry->srid() != PROJ_LATLONG) { throw std::runtime_error{ "Can not transform already transformed geometry."}; } diff --git a/src/flex-lua-table.cpp b/src/flex-lua-table.cpp index 3a41bcc1e..d7239706a 100644 --- a/src/flex-lua-table.cpp +++ b/src/flex-lua-table.cpp @@ -16,6 +16,7 @@ #include "lua-utils.hpp" #include "output-flex.hpp" #include "pgsql-capabilities.hpp" +#include "projection.hpp" #include "util.hpp" #include @@ -219,7 +220,7 @@ void parse_and_set_expire_options(lua_State *lua_state, return; } - if (!column->is_geometry_column() || column->srid() != 3857) { + if (!column->is_geometry_column() || column->srid() != PROJ_SPHERE_MERC) { throw std::runtime_error{"Expire only allowed for geometry" " columns in Web Mercator projection."}; } diff --git a/src/flex-table-column.cpp b/src/flex-table-column.cpp index 3ba3c4b67..57ed471ff 100644 --- a/src/flex-table-column.cpp +++ b/src/flex-table-column.cpp @@ -11,6 +11,7 @@ #include "format.hpp" #include "pgsql-capabilities.hpp" +#include "projection.hpp" #include "util.hpp" #include @@ -105,12 +106,12 @@ void flex_table_column_t::set_projection(char const *projection) auto const proj = lowercase(projection); if (proj == "merc" || proj == "mercator") { - m_srid = 3857; + m_srid = PROJ_SPHERE_MERC; return; } if (proj == "latlong" || proj == "latlon" || proj == "wgs84") { - m_srid = 4326; + m_srid = PROJ_LATLONG; return; } @@ -197,7 +198,7 @@ std::string flex_table_column_t::sql_create() const void flex_table_column_t::add_expire(expire_config_t const &config) { assert(is_geometry_column()); - assert(srid() == 3857); + assert(srid() == PROJ_SPHERE_MERC); m_expires.push_back(config); } diff --git a/src/flex-table-column.hpp b/src/flex-table-column.hpp index 4d445ed71..d19edef5b 100644 --- a/src/flex-table-column.hpp +++ b/src/flex-table-column.hpp @@ -13,6 +13,7 @@ #include "expire-config.hpp" #include "expire-tiles.hpp" #include "geom.hpp" +#include "projection.hpp" #include #include @@ -99,7 +100,7 @@ class flex_table_column_t bool needs_isvalid() const noexcept { assert(is_geometry_column()); - return !m_create_only && m_srid != 4326 && + return !m_create_only && m_srid != PROJ_LATLONG && m_type != table_column_type::point; } @@ -158,7 +159,7 @@ class flex_table_column_t /** * For geometry columns only: The projection SRID. Default is web mercator. */ - int m_srid = 3857; + int m_srid = PROJ_SPHERE_MERC; /// NOT NULL constraint bool m_not_null = false; diff --git a/src/flex-table.hpp b/src/flex-table.hpp index d5bd5198f..489496bf2 100644 --- a/src/flex-table.hpp +++ b/src/flex-table.hpp @@ -14,6 +14,7 @@ #include "flex-index.hpp" #include "flex-table-column.hpp" #include "pgsql.hpp" +#include "projection.hpp" #include "reprojection.hpp" #include "thread-pool.hpp" #include "util.hpp" @@ -145,7 +146,7 @@ class flex_table_t int srid() const noexcept { - return has_geom_column() ? geom_column().srid() : 4326; + return has_geom_column() ? geom_column().srid() : PROJ_LATLONG; } std::string build_sql_prepare_get_wkb() const; diff --git a/src/gen/gen-rivers.cpp b/src/gen/gen-rivers.cpp index 54aaba8ef..111291738 100644 --- a/src/gen/gen-rivers.cpp +++ b/src/gen/gen-rivers.cpp @@ -14,6 +14,7 @@ #include "logging.hpp" #include "params.hpp" #include "pgsql.hpp" +#include "projection.hpp" #include "util.hpp" #include "wkb.hpp" @@ -341,7 +342,7 @@ SELECT "{id_column}", "{width_column}", "{name_column}", "{geom_column}" timer(m_timer_write).start(); connection().exec("BEGIN"); for (auto &edge : edges) { - geom::geometry_t const geom{std::move(edge.points), 3857}; + geom::geometry_t const geom{std::move(edge.points), PROJ_SPHERE_MERC}; auto const wkb = geom_to_ewkb(geom); connection().exec_prepared("ins", edge.id, edge.width, get_name(names, edge.id), binary_param(wkb)); diff --git a/src/gen/raster.hpp b/src/gen/raster.hpp index 8708789a2..c1cf895bc 100644 --- a/src/gen/raster.hpp +++ b/src/gen/raster.hpp @@ -10,6 +10,8 @@ * For a full list of authors see the git log. */ +#include "projection.hpp" + #include #include @@ -41,7 +43,7 @@ struct wkb_raster_header double ipY = 0.0; double skewX = 0.0; double skewY = 0.0; - int32_t srid = 3857; + int32_t srid = PROJ_SPHERE_MERC; uint16_t width = 0; uint16_t height = 0; }; diff --git a/src/gen/tracer.cpp b/src/gen/tracer.cpp index 7f9eb9296..b8e54826e 100644 --- a/src/gen/tracer.cpp +++ b/src/gen/tracer.cpp @@ -11,6 +11,7 @@ #include "canvas.hpp" #include "geom-boost-adaptor.hpp" +#include "projection.hpp" #include "tile.hpp" #include @@ -114,7 +115,7 @@ tracer_t::build_geometries(tile_t const &tile, potrace_path_t const *plist, m_num_points += ring.size(); if (path->sign == '+') { - geometries.emplace_back(geom::polygon_t{}, 3857) + geometries.emplace_back(geom::polygon_t{}, PROJ_SPHERE_MERC) .get() .outer() = std::move(ring); } else { diff --git a/src/geom-functions.cpp b/src/geom-functions.cpp index a6db4c9ca..369f9f32c 100644 --- a/src/geom-functions.cpp +++ b/src/geom-functions.cpp @@ -11,6 +11,7 @@ #include "geom-boost-adaptor.hpp" #include "overloaded.hpp" +#include "projection.hpp" #include #include @@ -228,7 +229,7 @@ class transform_visitor void transform(geometry_t *output, geometry_t const &input, reprojection const &reprojection) { - assert(input.srid() == 4326); + assert(input.srid() == PROJ_LATLONG); set_to_same_type(output, input); output->set_srid(reprojection.target_srs()); @@ -385,7 +386,7 @@ double spherical_area(polygon_t const &geom) double spherical_area(geometry_t const &geom) { - assert(geom.srid() == 4326); + assert(geom.srid() == PROJ_LATLONG); return std::abs(geom.visit(overloaded{ [&](geom::nullgeom_t const & /*input*/) { return 0.0; }, diff --git a/src/geom.hpp b/src/geom.hpp index 250f88081..ac71c7653 100644 --- a/src/geom.hpp +++ b/src/geom.hpp @@ -16,6 +16,8 @@ * Basic geometry types and functions. */ +#include "projection.hpp" + #include #include @@ -274,31 +276,33 @@ class geometry_t // point_t is small and trivially copyable, no move needed like for the // other constructors. - constexpr explicit geometry_t(point_t geom, int srid = 4326) + constexpr explicit geometry_t(point_t geom, int srid = PROJ_LATLONG) : m_geom(geom), m_srid(srid) {} - constexpr explicit geometry_t(linestring_t &&geom, int srid = 4326) + constexpr explicit geometry_t(linestring_t &&geom, int srid = PROJ_LATLONG) : m_geom(std::move(geom)), m_srid(srid) {} - constexpr explicit geometry_t(polygon_t &&geom, int srid = 4326) + constexpr explicit geometry_t(polygon_t &&geom, int srid = PROJ_LATLONG) : m_geom(std::move(geom)), m_srid(srid) {} - constexpr explicit geometry_t(multipoint_t &&geom, int srid = 4326) + constexpr explicit geometry_t(multipoint_t &&geom, int srid = PROJ_LATLONG) : m_geom(std::move(geom)), m_srid(srid) {} - constexpr explicit geometry_t(multilinestring_t &&geom, int srid = 4326) + constexpr explicit geometry_t(multilinestring_t &&geom, + int srid = PROJ_LATLONG) : m_geom(std::move(geom)), m_srid(srid) {} - constexpr explicit geometry_t(multipolygon_t &&geom, int srid = 4326) + constexpr explicit geometry_t(multipolygon_t &&geom, + int srid = PROJ_LATLONG) : m_geom(std::move(geom)), m_srid(srid) {} - constexpr explicit geometry_t(collection_t &&geom, int srid = 4326) + constexpr explicit geometry_t(collection_t &&geom, int srid = PROJ_LATLONG) : m_geom(std::move(geom)), m_srid(srid) {} @@ -397,7 +401,7 @@ class geometry_t multilinestring_t, multipolygon_t, collection_t> m_geom = nullgeom_t{}; - int m_srid = 4326; + int m_srid = PROJ_LATLONG; }; // class geometry_t diff --git a/src/locator.cpp b/src/locator.cpp index 844eae364..73e49ef87 100644 --- a/src/locator.cpp +++ b/src/locator.cpp @@ -16,6 +16,7 @@ #include "overloaded.hpp" #include "pgsql-capabilities.hpp" #include "pgsql.hpp" +#include "projection.hpp" #include "wkb.hpp" #include @@ -63,7 +64,7 @@ void locator_t::add_regions(pg_conn_t const &db_connection, std::string const name = result.get_value(n, 0); auto geometry = ewkb_to_geom(util::decode_hex(result.get(n, 1))); - if (geometry.srid() == 4326) { + if (geometry.srid() == PROJ_LATLONG) { add_region(name, geometry); } else { log_warn("Ignoring locator geometry that is not in WGS84 (4326)"); diff --git a/src/output-flex.cpp b/src/output-flex.cpp index 1428f102f..197d77937 100644 --- a/src/output-flex.cpp +++ b/src/output-flex.cpp @@ -33,6 +33,7 @@ #include "osmtypes.hpp" #include "pgsql-capabilities.hpp" #include "pgsql.hpp" +#include "projection.hpp" #include "properties.hpp" #include "reprojection.hpp" #include "thread-pool.hpp" @@ -1191,8 +1192,9 @@ output_flex_t::output_flex_t(output_flex_t const *other, } for (auto &expire_output : *m_expire_outputs) { - m_expire_tiles.emplace_back(expire_output.maxzoom(), - reprojection::create_projection(3857)); + m_expire_tiles.emplace_back( + expire_output.maxzoom(), + reprojection::create_projection(PROJ_SPHERE_MERC)); } } @@ -1235,7 +1237,8 @@ output_flex_t::output_flex_t(std::shared_ptr const &mid, eo.set_maxzoom(options.expire_tiles_zoom); for (auto &table : *m_tables) { - if (table.has_geom_column() && table.geom_column().srid() == 3857) { + if (table.has_geom_column() && + table.geom_column().srid() == PROJ_SPHERE_MERC) { expire_config_t config{}; config.expire_output = m_expire_outputs->size() - 1; if (options.expire_tiles_max_bbox > 0.0) { @@ -1255,8 +1258,9 @@ output_flex_t::output_flex_t(std::shared_ptr const &mid, } for (auto &expire_output : *m_expire_outputs) { - m_expire_tiles.emplace_back(expire_output.maxzoom(), - reprojection::create_projection(3857)); + m_expire_tiles.emplace_back( + expire_output.maxzoom(), + reprojection::create_projection(PROJ_SPHERE_MERC)); } create_expire_tables(*m_expire_outputs, get_options()->connection_params); diff --git a/src/output-pgsql.cpp b/src/output-pgsql.cpp index 51b078d8d..8167645d4 100644 --- a/src/output-pgsql.cpp +++ b/src/output-pgsql.cpp @@ -38,6 +38,7 @@ #include "osmtypes.hpp" #include "output-pgsql.hpp" #include "pgsql.hpp" +#include "projection.hpp" #include "reprojection.hpp" #include "taginfo-impl.hpp" #include "tagtransform.hpp" @@ -51,7 +52,7 @@ double calculate_area(bool reproject_area, geom::geometry_t const &geom4326, geom::geometry_t const &projected_geom) { static thread_local auto const proj3857 = - reprojection::create_projection(3857); + reprojection::create_projection(PROJ_SPHERE_MERC); if (reproject_area) { auto const ogeom = geom::transform(geom4326, *proj3857); diff --git a/src/projection.hpp b/src/projection.hpp new file mode 100644 index 000000000..b3230039a --- /dev/null +++ b/src/projection.hpp @@ -0,0 +1,16 @@ +#ifndef OSM2PGSQL_PROJECTION_HPP +#define OSM2PGSQL_PROJECTION_HPP + +/** + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This file is part of osm2pgsql (https://osm2pgsql.org/). + * + * Copyright (C) 2006-2025 by the osm2pgsql developer community. + * For a full list of authors see the git log. + */ + +constexpr int PROJ_LATLONG = 4326; +constexpr int PROJ_SPHERE_MERC = 3857; + +#endif // OSM2PGSQL_PROJECTION_HPP diff --git a/src/reprojection.hpp b/src/reprojection.hpp index 50d17e65a..e1de8c90f 100644 --- a/src/reprojection.hpp +++ b/src/reprojection.hpp @@ -17,16 +17,11 @@ */ #include "geom.hpp" +#include "projection.hpp" #include #include -enum Projection -{ - PROJ_LATLONG = 4326, - PROJ_SPHERE_MERC = 3857 -}; - /** * Virtual base class used for projecting OSM WGS84 coordinates into a * different coordinate system. Most commonly this will be used to convert diff --git a/tests/test-expire-from-geometry.cpp b/tests/test-expire-from-geometry.cpp index ae5f5f532..f0c73c47f 100644 --- a/tests/test-expire-from-geometry.cpp +++ b/tests/test-expire-from-geometry.cpp @@ -13,6 +13,7 @@ #include #include "expire-tiles.hpp" +#include "projection.hpp" #include "reprojection.hpp" #include "tile-output.hpp" #include "tile.hpp" @@ -42,7 +43,7 @@ TEST_CASE("expire null geometry does nothing", "[NoDB]") SECTION("geom with check") { geom::geometry_t geom{}; - geom.set_srid(3857); + geom.set_srid(PROJ_SPHERE_MERC); et.from_geometry_if_3857(geom, expire_config); } @@ -67,7 +68,7 @@ TEST_CASE("expire point at tile boundary", "[NoDB]") SECTION("geom with check") { geom::geometry_t geom{pt}; - geom.set_srid(3857); + geom.set_srid(PROJ_SPHERE_MERC); et.from_geometry_if_3857(geom, expire_config); } @@ -97,7 +98,7 @@ TEST_CASE("expire point away from tile boundary", "[NoDB]") SECTION("geom with check") { geom::geometry_t geom{pt}; - geom.set_srid(3857); + geom.set_srid(PROJ_SPHERE_MERC); et.from_geometry_if_3857(geom, expire_config); } @@ -128,7 +129,7 @@ TEST_CASE("expire linestring away from tile boundary", "[NoDB]") { geom::linestring_t line{{5000.0, 4000.0}, {5100.0, 4200.0}}; geom::geometry_t geom{std::move(line)}; - geom.set_srid(3857); + geom.set_srid(PROJ_SPHERE_MERC); et.from_geometry_if_3857(geom, expire_config); } @@ -159,7 +160,7 @@ TEST_CASE("expire linestring crossing tile boundary", "[NoDB]") { geom::linestring_t line{{5000.0, 5000.0}, {5000.0, 15000.0}}; geom::geometry_t geom{std::move(line)}; - geom.set_srid(3857); + geom.set_srid(PROJ_SPHERE_MERC); et.from_geometry_if_3857(geom, expire_config); } @@ -203,7 +204,7 @@ TEST_CASE("expire small polygon", "[NoDB]") {5000.0, 5100.0}, {5000.0, 5000.0}}}; geom::geometry_t geom{std::move(poly)}; - geom.set_srid(3857); + geom.set_srid(PROJ_SPHERE_MERC); et.from_geometry_if_3857(geom, expire_config); } @@ -248,7 +249,7 @@ TEST_CASE("expire large polygon as bbox", "[NoDB]") {5000.0, 25000.0}, {5000.0, 5000.0}}}; geom::geometry_t geom{std::move(poly)}; - geom.set_srid(3857); + geom.set_srid(PROJ_SPHERE_MERC); et.from_geometry_if_3857(geom, expire_config); } @@ -313,7 +314,7 @@ TEST_CASE("expire large polygon as boundary", "[NoDB]") {5000.0, 25000.0}, {5000.0, 5000.0}}}; geom::geometry_t geom{std::move(poly)}; - geom.set_srid(3857); + geom.set_srid(PROJ_SPHERE_MERC); et.from_geometry_if_3857(geom, expire_config); } @@ -362,7 +363,7 @@ TEST_CASE("expire multipoint geometry", "[NoDB]") mpt.add_geometry(p1); mpt.add_geometry(p2); geom::geometry_t geom{std::move(mpt)}; - geom.set_srid(3857); + geom.set_srid(PROJ_SPHERE_MERC); et.from_geometry_if_3857(geom, expire_config); } @@ -485,7 +486,7 @@ TEST_CASE("expire works if in 3857", "[NoDB]") expire_tiles et{zoom, defproj}; geom::geometry_t geom{geom::point_t{0.0, 0.0}}; - geom.set_srid(3857); + geom.set_srid(PROJ_SPHERE_MERC); et.from_geometry_if_3857(geom, expire_config); auto const tiles = et.get_tiles(); diff --git a/tests/test-geom-multilinestrings.cpp b/tests/test-geom-multilinestrings.cpp index 0ae2e0e63..2fbeb54d9 100644 --- a/tests/test-geom-multilinestrings.cpp +++ b/tests/test-geom-multilinestrings.cpp @@ -15,6 +15,7 @@ #include "geom-functions.hpp" #include "geom-output.hpp" #include "geom.hpp" +#include "projection.hpp" #include @@ -343,7 +344,7 @@ TEST_CASE("create_multilinestring and simplify", "[NoDB]") geom::create_multilinestring(buffer.buffer()); REQUIRE(geom.is_multilinestring()); - REQUIRE(geom.srid() == 4326); + REQUIRE(geom.srid() == PROJ_LATLONG); auto const &mls = geom.get(); REQUIRE(mls.num_geometries() == 2); REQUIRE(mls[0] == geom::linestring_t{{1, 1}, {1, 2}, {1, 3}}); @@ -353,7 +354,7 @@ TEST_CASE("create_multilinestring and simplify", "[NoDB]") { auto const simplified_geom = geom::simplify(geom, 0.1); REQUIRE(simplified_geom.is_multilinestring()); - REQUIRE(simplified_geom.srid() == 4326); + REQUIRE(simplified_geom.srid() == PROJ_LATLONG); auto const &simplified_mls = simplified_geom.get(); REQUIRE(simplified_mls.num_geometries() == 2); @@ -366,7 +367,7 @@ TEST_CASE("create_multilinestring and simplify", "[NoDB]") { auto const simplified_geom = geom::simplify(geom, 10.0); REQUIRE(simplified_geom.is_multilinestring()); - REQUIRE(simplified_geom.srid() == 4326); + REQUIRE(simplified_geom.srid() == PROJ_LATLONG); auto const &simplified_mls = simplified_geom.get(); REQUIRE(simplified_mls.num_geometries() == 2); diff --git a/tests/test-geom-transform.cpp b/tests/test-geom-transform.cpp index 8481b1313..10a7ed775 100644 --- a/tests/test-geom-transform.cpp +++ b/tests/test-geom-transform.cpp @@ -12,6 +12,7 @@ #include "geom-functions.hpp" #include "geom-output.hpp" #include "geom.hpp" +#include "projection.hpp" #include "reprojection.hpp" namespace { @@ -47,7 +48,7 @@ TEST_CASE("Transform geom::null_t", "[NoDB]") geom::geometry_t const geom{}; auto const result = geom::transform(geom, *reprojection); REQUIRE(result.is_null()); - REQUIRE(result.srid() == 3857); + REQUIRE(result.srid() == PROJ_SPHERE_MERC); } TEST_CASE("Transform geom::point_t", "[NoDB]") @@ -58,7 +59,7 @@ TEST_CASE("Transform geom::point_t", "[NoDB]") geom::geometry_t const geom{geom::point_t{5.5, 4.4}}; auto const result = geom::transform(geom, *reprojection); REQUIRE(result.is_point()); - REQUIRE(result.srid() == 3857); + REQUIRE(result.srid() == PROJ_SPHERE_MERC); check(result.get(), geom::point_t{612257.1993630046, 490287.90003313165}); @@ -72,7 +73,7 @@ TEST_CASE("Transform geom::linestring_t", "[NoDB]") geom::geometry_t const geom{geom::linestring_t{{5.5, 4.4}, {3.3, 2.2}}}; auto const result = geom::transform(geom, *reprojection); REQUIRE(result.is_linestring()); - REQUIRE(result.srid() == 3857); + REQUIRE(result.srid() == PROJ_SPHERE_MERC); auto const &r = result.get(); check(r[0], geom::point_t{X55, Y44}); @@ -91,7 +92,7 @@ TEST_CASE("Transform geom::polygon_t", "[NoDB]") auto const result = geom::transform(geom, *reprojection); REQUIRE(result.is_polygon()); - REQUIRE(result.srid() == 3857); + REQUIRE(result.srid() == PROJ_SPHERE_MERC); auto const &polygon = result.get(); auto const &outer = polygon.outer(); @@ -125,7 +126,7 @@ TEST_CASE("Transform geom::multipoint_t", "[NoDB]") auto const result = geom::transform(geom, *reprojection); REQUIRE(result.is_multipoint()); - REQUIRE(result.srid() == 3857); + REQUIRE(result.srid() == PROJ_SPHERE_MERC); auto const &rmp = result.get(); REQUIRE(rmp.num_geometries() == 2); @@ -145,7 +146,7 @@ TEST_CASE("Transform geom::multilinestring_t", "[NoDB]") auto const result = geom::transform(geom, *reprojection); REQUIRE(result.is_multilinestring()); - REQUIRE(result.srid() == 3857); + REQUIRE(result.srid() == PROJ_SPHERE_MERC); auto const &rml = result.get(); REQUIRE(rml.num_geometries() == 2); @@ -173,7 +174,7 @@ TEST_CASE("Transform geom::multipolygon_t", "[NoDB]") auto const result = geom::transform(geom, *reprojection); REQUIRE(result.is_multipolygon()); - REQUIRE(result.srid() == 3857); + REQUIRE(result.srid() == PROJ_SPHERE_MERC); auto const &rmp = result.get(); REQUIRE(rmp.num_geometries() == 2); @@ -218,7 +219,7 @@ TEST_CASE("Transform geom::collection_t", "[NoDB]") auto const result = geom::transform(geom, *reprojection); REQUIRE(result.is_collection()); - REQUIRE(result.srid() == 3857); + REQUIRE(result.srid() == PROJ_SPHERE_MERC); auto const &rc = result.get(); REQUIRE(rc.num_geometries() == 4); diff --git a/tests/test-reprojection.cpp b/tests/test-reprojection.cpp index fa14af84a..0818d477c 100644 --- a/tests/test-reprojection.cpp +++ b/tests/test-reprojection.cpp @@ -9,12 +9,13 @@ #include +#include "projection.hpp" #include "reprojection.hpp" TEST_CASE("projection 4326", "[NoDB]") { osmium::Location const loc{10.0, 53.0}; - int const srs = 4326; + int const srs = PROJ_LATLONG; auto const reprojection = reprojection::create_projection(srs); REQUIRE(reprojection->target_srs() == srs); @@ -32,7 +33,7 @@ TEST_CASE("projection 4326", "[NoDB]") TEST_CASE("projection 3857", "[NoDB]") { osmium::Location const loc{10.0, 53.0}; - int const srs = 3857; + int const srs = PROJ_SPHERE_MERC; auto const reprojection = reprojection::create_projection(srs); REQUIRE(reprojection->target_srs() == srs); @@ -52,7 +53,7 @@ TEST_CASE("projection 3857 bounds", "[NoDB]") osmium::Location const loc1{0.0, 0.0}; osmium::Location const loc2{-180.0, -85.0511288}; osmium::Location const loc3{180.0, 85.0511288}; - int const srs = 3857; + int const srs = PROJ_SPHERE_MERC; auto const reprojection = reprojection::create_projection(srs); {