diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2022-02-14 20:00:25 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2022-02-14 20:00:25 +0100 |
| commit | df9e2fe519d97139a8264057d96b034788e8e8e7 (patch) | |
| tree | 0ac30dd48e217392fcf1b3937e025adaa81b9730 /test | |
| parent | f67c82912fde55a58d565697263306c840b3efd4 (diff) | |
| download | PROJ-df9e2fe519d97139a8264057d96b034788e8e8e7.tar.gz PROJ-df9e2fe519d97139a8264057d96b034788e8e8e7.zip | |
Better deal with importing strings like '+init=epsg:XXXX +over' (refs MapServer/MapServer#6478)
Diffstat (limited to 'test')
| -rw-r--r-- | test/unit/test_c_api.cpp | 38 | ||||
| -rw-r--r-- | test/unit/test_io.cpp | 4 |
2 files changed, 40 insertions, 2 deletions
diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp index 3e6ef1ab..ecbb2999 100644 --- a/test/unit/test_c_api.cpp +++ b/test/unit/test_c_api.cpp @@ -5392,6 +5392,44 @@ TEST_F(CApi, use_proj4_init_rules) { PJ_CONTEXT *ctx = proj_context_create(); proj_context_use_proj4_init_rules(ctx, true); ASSERT_TRUE(proj_context_get_use_proj4_init_rules(ctx, true)); + + { + // Test +over + auto crs = proj_create(ctx, "+init=epsg:28992 +over"); + ObjectKeeper keeper_crs(crs); + ASSERT_NE(crs, nullptr); + + auto datum = proj_crs_get_datum(ctx, crs); + ASSERT_NE(datum, nullptr); + ObjectKeeper keeper_datum(datum); + + auto datum_name = proj_get_name(datum); + ASSERT_TRUE(datum_name != nullptr); + EXPECT_EQ(datum_name, std::string("Amersfoort")); + + auto proj_5 = proj_as_proj_string(ctx, crs, PJ_PROJ_5, nullptr); + ASSERT_NE(proj_5, nullptr); + EXPECT_EQ(std::string(proj_5), + "+proj=sterea +lat_0=52.1561605555556 " + "+lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 " + "+y_0=463000 +ellps=bessel +units=m +over " + "+no_defs +type=crs"); + } + + { + // Test +over on epsg:3857 + auto crs = proj_create(ctx, "+init=epsg:3857 +over"); + ObjectKeeper keeper_crs(crs); + ASSERT_NE(crs, nullptr); + + auto proj_5 = proj_as_proj_string(ctx, crs, PJ_PROJ_5, nullptr); + ASSERT_NE(proj_5, nullptr); + EXPECT_EQ(std::string(proj_5), + "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 " + "+y_0=0 +k=1 +units=m +nadgrids=@null +over +wktext " + "+no_defs +type=crs"); + } + proj_context_use_proj4_init_rules(ctx, false); ASSERT_TRUE(!proj_context_get_use_proj4_init_rules(ctx, true)); proj_context_destroy(ctx); diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp index 1c7fc812..33f4c731 100644 --- a/test/unit/test_io.cpp +++ b/test/unit/test_io.cpp @@ -10531,13 +10531,13 @@ TEST(io, projparse_init) { } { - auto obj = createFromUserInput("+title=mytitle +over +init=epsg:4326", + auto obj = createFromUserInput("+title=mytitle +init=epsg:4326 +over", dbContext, true); auto crs = nn_dynamic_pointer_cast<GeographicCRS>(obj); ASSERT_TRUE(crs != nullptr); EXPECT_EQ(crs->nameStr(), "mytitle"); EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=longlat +over +datum=WGS84 +no_defs +type=crs"); + "+proj=longlat +datum=WGS84 +over +no_defs +type=crs"); } { |
