diff options
| author | dalia2 <57895979+dalia2@users.noreply.github.com> | 2019-12-12 14:25:40 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-12 14:25:40 +0000 |
| commit | 1efec9523d21e7948db2d278635c8881409b9cf8 (patch) | |
| tree | 2ac7fde4db93e75c109d65f2c596275a02a3cc06 /test/unit | |
| parent | e9d6a0b2993c903c8932b68d2812dc02adb26014 (diff) | |
| parent | 5b4e60f4f9ec353f79fba01790a3b945c50cab8e (diff) | |
| download | PROJ-1efec9523d21e7948db2d278635c8881409b9cf8.tar.gz PROJ-1efec9523d21e7948db2d278635c8881409b9cf8.zip | |
Merge branch 'master' into update-grid-alternatives.sql-for-Icealnd
Diffstat (limited to 'test/unit')
| -rw-r--r-- | test/unit/gie_self_tests.cpp | 4 | ||||
| -rw-r--r-- | test/unit/test_crs.cpp | 32 | ||||
| -rw-r--r-- | test/unit/test_factory.cpp | 2 | ||||
| -rw-r--r-- | test/unit/test_io.cpp | 35 | ||||
| -rw-r--r-- | test/unit/test_operation.cpp | 27 |
5 files changed, 97 insertions, 3 deletions
diff --git a/test/unit/gie_self_tests.cpp b/test/unit/gie_self_tests.cpp index 15db814a..a738db75 100644 --- a/test/unit/gie_self_tests.cpp +++ b/test/unit/gie_self_tests.cpp @@ -386,6 +386,10 @@ TEST(gie, info_functions) { grid_info = proj_grid_info("nonexistinggrid"); ASSERT_EQ(std::string(grid_info.filename), ""); + // File exists, but is not a grid + grid_info = proj_grid_info("proj.db"); + ASSERT_EQ(std::string(grid_info.filename), ""); + /* proj_init_info() */ init_info = proj_init_info("unknowninit"); ASSERT_EQ(std::string(init_info.filename), ""); diff --git a/test/unit/test_crs.cpp b/test/unit/test_crs.cpp index 427fd741..e896853f 100644 --- a/test/unit/test_crs.cpp +++ b/test/unit/test_crs.cpp @@ -2281,6 +2281,38 @@ TEST(crs, projectedCRS_identify_db) { // --------------------------------------------------------------------------- +TEST(crs, projectedCRS_identify_wrong_auth_name_case) { + auto dbContext = DatabaseContext::create(); + auto factoryAnonymous = AuthorityFactory::create(dbContext, std::string()); + auto obj = + WKTParser() + .attachDatabaseContext(dbContext) + .setStrict(false) + .createFromWKT( + "PROJCS[\"World_Cylindrical_Equal_Area\"," + "GEOGCS[\"GCS_WGS_1984\"," + "DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\"," + "6378137.0,298.257223563]]," + "PRIMEM[\"Greenwich\",0.0]," + "UNIT[\"Degree\",0.0174532925199433]]," + "PROJECTION[\"Cylindrical_Equal_Area\"]," + "PARAMETER[\"False_Easting\",0.0]," + "PARAMETER[\"False_Northing\",0.0]," + "PARAMETER[\"Central_Meridian\",0.0]," + "PARAMETER[\"Standard_Parallel_1\",0.0],UNIT[\"Meter\",1.0]," + "AUTHORITY[\"Esri\",54034]]"); // should be ESRI all caps + auto crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj); + ASSERT_TRUE(crs != nullptr); + auto res = crs->identify(factoryAnonymous); + ASSERT_EQ(res.size(), 1U); + const auto &ids = res.front().first->identifiers(); + ASSERT_EQ(ids.size(), 1U); + EXPECT_EQ(*(ids.front()->codeSpace()), "ESRI"); + EXPECT_EQ(ids.front()->code(), "54034"); +} + +// --------------------------------------------------------------------------- + TEST(crs, mercator_1SP_as_WKT1_ESRI) { auto obj = PROJStringParser().createFromPROJString( diff --git a/test/unit/test_factory.cpp b/test/unit/test_factory.cpp index 93b2ef34..0d47bfc3 100644 --- a/test/unit/test_factory.cpp +++ b/test/unit/test_factory.cpp @@ -2872,7 +2872,7 @@ TEST(factory, getMetadata) { EXPECT_EQ(ctxt->getMetadata("i_do_not_exist"), nullptr); const char *IGNF_VERSION = ctxt->getMetadata("IGNF.VERSION"); ASSERT_TRUE(IGNF_VERSION != nullptr); - EXPECT_EQ(std::string(IGNF_VERSION), "3.0.3"); + EXPECT_EQ(std::string(IGNF_VERSION), "3.1.0"); } // --------------------------------------------------------------------------- diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp index 552eb5bf..38dfc2b4 100644 --- a/test/unit/test_io.cpp +++ b/test/unit/test_io.cpp @@ -8186,9 +8186,10 @@ TEST(io, projparse_merc_variant_B) { // --------------------------------------------------------------------------- TEST(io, projparse_merc_google_mercator) { - auto obj = PROJStringParser().createFromPROJString( + auto projString = "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 " - "+k=1 +units=m +nadgrids=@null +type=crs"); + "+k=1 +units=m +nadgrids=@null +no_defs +type=crs"; + auto obj = PROJStringParser().createFromPROJString(projString); auto crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj); ASSERT_TRUE(crs != nullptr); WKTFormatterNNPtr f(WKTFormatter::create()); @@ -8202,6 +8203,36 @@ TEST(io, projparse_merc_google_mercator) { EXPECT_TRUE(wkt.find("DATUM[\"World Geodetic System 1984\"") != std::string::npos) << wkt; + + EXPECT_EQ( + replaceAll(crs->exportToPROJString(PROJStringFormatter::create().get()), + " +wktext", ""), + projString); +} + +// --------------------------------------------------------------------------- + +TEST(io, projparse_merc_not_quite_google_mercator) { + auto projString = + "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=10 +x_0=0 +y_0=0 " + "+k=1 +units=m +nadgrids=@null +no_defs +type=crs"; + auto obj = PROJStringParser().createFromPROJString(projString); + auto crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj); + ASSERT_TRUE(crs != nullptr); + WKTFormatterNNPtr f(WKTFormatter::create()); + f->simulCurNodeHasId(); + f->setMultiLine(false); + crs->exportToWKT(f.get()); + auto wkt = f->toString(); + EXPECT_TRUE(wkt.find("METHOD[\"Popular Visualisation Pseudo " + "Mercator\",ID[\"EPSG\",1024]") != std::string::npos) + << wkt; + EXPECT_TRUE(wkt.find("DATUM[\"unknown\",") != std::string::npos) << wkt; + + EXPECT_EQ( + replaceAll(crs->exportToPROJString(PROJStringFormatter::create().get()), + " +wktext", ""), + projString); } // --------------------------------------------------------------------------- diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp index 9cde8822..9cf03555 100644 --- a/test/unit/test_operation.cpp +++ b/test/unit/test_operation.cpp @@ -4628,6 +4628,33 @@ TEST(operation, geogCRS_to_geogCRS_context_WGS84_G1674_to_WGS84_G1762) { // --------------------------------------------------------------------------- +TEST(operation, geogCRS_to_geogCRS_context_EPSG_4240_Indian1975_to_EPSG_4326) { + auto authFactory = + AuthorityFactory::create(DatabaseContext::create(), "EPSG"); + auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0); + ctxt->setSpatialCriterion( + CoordinateOperationContext::SpatialCriterion::PARTIAL_INTERSECTION); + + auto list = CoordinateOperationFactory::create()->createOperations( + authFactory->createCoordinateReferenceSystem("4240"), // Indian 1975 + authFactory->createCoordinateReferenceSystem("4326"), ctxt); + ASSERT_EQ(list.size(), 3U); + + // Indian 1975 to WGS 84 (4), 3.0 m, Thailand - onshore + EXPECT_EQ(list[0]->getEPSGCode(), 1812); + + // The following is the one we want to see. It has a lesser accuracy than + // the above one and the same bbox, but the name of its area of use is + // slightly different + // Indian 1975 to WGS 84 (2), 5.0 m, Thailand - onshore and Gulf of Thailand + EXPECT_EQ(list[1]->getEPSGCode(), 1304); + + // Indian 1975 to WGS 84 (3), 1.0 m, Thailand - Bongkot field + EXPECT_EQ(list[2]->getEPSGCode(), 1537); +} + +// --------------------------------------------------------------------------- + TEST(operation, vertCRS_to_geogCRS_context) { auto authFactory = AuthorityFactory::create(DatabaseContext::create(), "EPSG"); |
