Skip to content

Commit

Permalink
Remove support for projection using the Proj library
Browse files Browse the repository at this point in the history
This has been deprecated a while because it only works with very old
versions of the Proj library.
  • Loading branch information
joto committed Dec 16, 2024
1 parent 83424e2 commit 711721c
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 312 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ if(BUILD_HEADERS)
file(MAKE_DIRECTORY header_check)

foreach(hpp ${ALL_HPPS})
if((GDAL_FOUND AND PROJ_FOUND) OR NOT ((hpp STREQUAL "osmium/area/problem_reporter_ogr.hpp") OR (hpp STREQUAL "osmium/geom/ogr.hpp") OR (hpp STREQUAL "osmium/geom/projection.hpp")))
if((GDAL_FOUND) OR NOT ((hpp STREQUAL "osmium/area/problem_reporter_ogr.hpp") OR (hpp STREQUAL "osmium/geom/ogr.hpp")))
string(REPLACE ".hpp" "" tmp ${hpp})
string(REPLACE "/" "__" libname ${tmp})

Expand Down
213 changes: 0 additions & 213 deletions include/osmium/geom/projection.hpp

This file was deleted.

9 changes: 2 additions & 7 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,6 @@ if(NOT GEOS_FOUND)
set(GEOS_FOUND FALSE)
endif()

if(NOT PROJ_FOUND)
set(PROJ_FOUND FALSE)
endif()

if(NOT SPARSEHASH_FOUND)
set(SPARSEHASH_FOUND FALSE)
endif()
Expand Down Expand Up @@ -157,15 +153,14 @@ add_unit_test(builder test_attr)
add_unit_test(builder test_object_builder)

add_unit_test(geom test_coordinates)
add_unit_test(geom test_crs ENABLE_IF ${PROJ_FOUND} LIBS ${PROJ_LIBRARY})
add_unit_test(geom test_exception)
add_unit_test(geom test_factory_with_projection ENABLE_IF ${PROJ_FOUND} LIBS ${PROJ_LIBRARY})
add_unit_test(geom test_factory_with_projection)
add_unit_test(geom test_geojson)
add_unit_test(geom test_geos ENABLE_IF ${GEOS_FOUND} LIBS ${GEOS_LIBRARY})
add_unit_test(geom test_mercator)
add_unit_test(geom test_ogr ENABLE_IF ${GDAL_FOUND} LIBS ${GDAL_LIBRARY})
add_unit_test(geom test_ogr_wkb ENABLE_IF ${GDAL_FOUND} LIBS ${GDAL_LIBRARY})
add_unit_test(geom test_projection ENABLE_IF ${PROJ_FOUND} LIBS ${PROJ_LIBRARY})
add_unit_test(geom test_projection)
add_unit_test(geom test_tile)
add_unit_test(geom test_wkb)
add_unit_test(geom test_wkt)
Expand Down
18 changes: 0 additions & 18 deletions test/t/geom/test_crs.cpp

This file was deleted.

8 changes: 0 additions & 8 deletions test/t/geom/test_factory_with_projection.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "catch.hpp"

#include <osmium/geom/mercator_projection.hpp>
#include <osmium/geom/projection.hpp>
#include <osmium/geom/wkt.hpp>

#include <string>
Expand All @@ -13,10 +12,3 @@ TEST_CASE("Projection using MercatorProjection class to WKT") {
REQUIRE(wkt == "POINT(356222.37 467961.14)");
}

TEST_CASE("Projection using Projection class to WKT") {
osmium::geom::WKTFactory<osmium::geom::Projection> factory{osmium::geom::Projection{3857}, 2};

const std::string wkt{factory.create_point(osmium::Location{3.2, 4.2})};
REQUIRE(wkt == "POINT(356222.37 467961.14)");
}

65 changes: 0 additions & 65 deletions test/t/geom/test_projection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,78 +2,13 @@

#include <osmium/geom/factory.hpp>
#include <osmium/geom/mercator_projection.hpp>
#include <osmium/geom/projection.hpp>

TEST_CASE("Indentity Projection") {
const osmium::geom::IdentityProjection projection;
REQUIRE(4326 == projection.epsg());
REQUIRE("+proj=longlat +datum=WGS84 +no_defs" == projection.proj_string());
}

TEST_CASE("Projection 4326") {
const osmium::geom::Projection projection{4326};
REQUIRE(4326 == projection.epsg());
REQUIRE("+init=epsg:4326" == projection.proj_string());

const osmium::Location loc{1.0, 2.0};
const osmium::geom::Coordinates c{1.0, 2.0};
REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.00001));
REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.00001));
}

TEST_CASE("Projection 4326 from init string") {
const osmium::geom::Projection projection{"+init=epsg:4326"};
REQUIRE(-1 == projection.epsg());
REQUIRE("+init=epsg:4326" == projection.proj_string());

const osmium::Location loc{1.0, 2.0};
const osmium::geom::Coordinates c{1.0, 2.0};
REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.00001));
REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.00001));
}

TEST_CASE("Creating projection from unknown init string") {
REQUIRE_THROWS_AS(osmium::geom::Projection{"abc"}, osmium::projection_error);
}

TEST_CASE("Creating projection from unknown EPSG code") {
REQUIRE_THROWS_AS(osmium::geom::Projection{9999999}, osmium::projection_error);
}

TEST_CASE("Projection 3857") {
const osmium::geom::Projection projection{3857};
REQUIRE(3857 == projection.epsg());
REQUIRE("+init=epsg:3857" == projection.proj_string());

SECTION("Zero coordinates") {
const osmium::Location loc{0.0, 0.0};
const osmium::geom::Coordinates c{0.0, 0.0};
REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.00001));
REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.00001));
}

SECTION("Max longitude") {
const osmium::Location loc{180.0, 0.0};
const osmium::geom::Coordinates c{20037508.34, 0.0};
REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.00001));
REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.00001));
}

SECTION("Min longitude") {
const osmium::Location loc{-180.0, 0.0};
const osmium::geom::Coordinates c{-20037508.34, 0.0};
REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.00001));
REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.00001));
}

SECTION("Max latitude") {
const osmium::Location loc{0.0, 85.0511288};
const osmium::geom::Coordinates c{0.0, 20037508.34};
REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.00001));
REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.00001));
}
}

TEST_CASE("MercatorProjection: Zero coordinates") {
const osmium::geom::MercatorProjection projection;
const osmium::Location loc{0.0, 0.0};
Expand Down

0 comments on commit 711721c

Please sign in to comment.