aboutsummaryrefslogtreecommitdiff
path: root/test/unit
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/test_crs.cpp88
-rw-r--r--test/unit/test_io.cpp31
-rw-r--r--test/unit/test_operation.cpp17
3 files changed, 136 insertions, 0 deletions
diff --git a/test/unit/test_crs.cpp b/test/unit/test_crs.cpp
index 987ffe1b..500ff4a4 100644
--- a/test/unit/test_crs.cpp
+++ b/test/unit/test_crs.cpp
@@ -747,6 +747,77 @@ TEST(crs, EPSG_4268_geogcrs_deprecated_as_WKT1_GDAL) {
// ---------------------------------------------------------------------------
+TEST(crs, ESRI_104971_as_WKT1_ESRI_with_database) {
+ auto dbContext = DatabaseContext::create();
+ auto factory = AuthorityFactory::create(dbContext, "ESRI");
+ auto crs = factory->createCoordinateReferenceSystem("104971");
+ WKTFormatterNNPtr f(WKTFormatter::create(
+ WKTFormatter::Convention::WKT1_ESRI, DatabaseContext::create()));
+ // Check that the _(Sphere) suffix is preserved
+ EXPECT_EQ(crs->exportToWKT(f.get()),
+ "GEOGCS[\"Mars_2000_(Sphere)\",DATUM[\"Mars_2000_(Sphere)\","
+ "SPHEROID[\"Mars_2000_(Sphere)\",3396190.0,0.0]],"
+ "PRIMEM[\"Reference_Meridian\",0.0],"
+ "UNIT[\"Degree\",0.0174532925199433]]");
+}
+
+// ---------------------------------------------------------------------------
+
+TEST(crs,
+ implicit_compound_ESRI_104024_plus_115844_as_WKT1_ESRI_with_database) {
+ auto dbContext = DatabaseContext::create();
+ auto obj = createFromUserInput("ESRI:104024+115844", dbContext);
+ auto crs = nn_dynamic_pointer_cast<GeographicCRS>(obj);
+ ASSERT_TRUE(crs != nullptr);
+ EXPECT_EQ(crs->coordinateSystem()->axisList().size(), 3U);
+ WKTFormatterNNPtr f(WKTFormatter::create(
+ WKTFormatter::Convention::WKT1_ESRI, DatabaseContext::create()));
+ // Situation where there is no EPSG official name
+ EXPECT_EQ(crs->exportToWKT(f.get()),
+ "GEOGCS[\"California_SRS_Epoch_2017.50_(NAD83)\","
+ "DATUM[\"California_SRS_Epoch_2017.50_(NAD83)\","
+ "SPHEROID[\"GRS_1980\",6378137.0,298.257222101]],"
+ "PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],"
+ "VERTCS[\"California_SRS_Epoch_2017.50_(NAD83)\","
+ "DATUM[\"California_SRS_Epoch_2017.50_(NAD83)\","
+ "SPHEROID[\"GRS_1980\",6378137.0,298.257222101]],"
+ "PARAMETER[\"Vertical_Shift\",0.0],"
+ "PARAMETER[\"Direction\",1.0],UNIT[\"Meter\",1.0]]");
+}
+
+// ---------------------------------------------------------------------------
+
+TEST(crs, implicit_compound_ESRI_104971_to_3D_as_WKT1_ESRI_with_database) {
+ auto dbContext = DatabaseContext::create();
+ auto factory = AuthorityFactory::create(dbContext, "ESRI");
+ auto crs = factory->createGeographicCRS("104971")->promoteTo3D(
+ std::string(), dbContext);
+ WKTFormatterNNPtr f(WKTFormatter::create(
+ WKTFormatter::Convention::WKT1_ESRI, DatabaseContext::create()));
+ // Situation where there is no ESRI vertical CRS, but the GEOGCS does exist
+ // This will be only partly recognized by ESRI software.
+ // See https://github.com/OSGeo/PROJ/issues/2757
+ const char *wkt = "GEOGCS[\"Mars_2000_(Sphere)\","
+ "DATUM[\"Mars_2000_(Sphere)\","
+ "SPHEROID[\"Mars_2000_(Sphere)\",3396190.0,0.0]],"
+ "PRIMEM[\"Reference_Meridian\",0.0],"
+ "UNIT[\"Degree\",0.0174532925199433]],"
+ "VERTCS[\"Mars_2000_(Sphere)\","
+ "DATUM[\"Mars_2000_(Sphere)\","
+ "SPHEROID[\"Mars_2000_(Sphere)\",3396190.0,0.0]],"
+ "PARAMETER[\"Vertical_Shift\",0.0],"
+ "PARAMETER[\"Direction\",1.0],"
+ "UNIT[\"Meter\",1.0]]";
+ EXPECT_EQ(crs->exportToWKT(f.get()), wkt);
+
+ auto obj2 = WKTParser().attachDatabaseContext(dbContext).createFromWKT(wkt);
+ auto crs2 = nn_dynamic_pointer_cast<GeographicCRS>(obj2);
+ ASSERT_TRUE(crs2 != nullptr);
+ EXPECT_EQ(crs2->coordinateSystem()->axisList().size(), 3U);
+}
+
+// ---------------------------------------------------------------------------
+
TEST(crs, IAU_1000_as_WKT2) {
auto dbContext = DatabaseContext::create();
auto factory = AuthorityFactory::create(dbContext, "IAU_2015");
@@ -3877,6 +3948,23 @@ TEST(crs, verticalCRS_down_as_WKT1_ESRI) {
// ---------------------------------------------------------------------------
+TEST(crs, verticalCRS_ESRI_115834_as_WKT1_ESRI_with_database) {
+ auto dbContext = DatabaseContext::create();
+ auto factory = AuthorityFactory::create(dbContext, "ESRI");
+ auto crs = factory->createCoordinateReferenceSystem("115834");
+ WKTFormatterNNPtr f(WKTFormatter::create(
+ WKTFormatter::Convention::WKT1_ESRI, DatabaseContext::create()));
+ // Check that the parentheses in the VERTCS and DATUM names are preserved
+ EXPECT_EQ(crs->exportToWKT(f.get()),
+ "VERTCS[\"NAD83(CSRS)v5\","
+ "DATUM[\"North_American_Datum_of_1983_(CSRS)_version_5\","
+ "SPHEROID[\"GRS_1980\",6378137.0,298.257222101]],"
+ "PARAMETER[\"Vertical_Shift\",0.0],"
+ "PARAMETER[\"Direction\",1.0],UNIT[\"Meter\",1.0]]");
+}
+
+// ---------------------------------------------------------------------------
+
TEST(crs, verticalCRS_identify_db) {
auto dbContext = DatabaseContext::create();
auto factory = AuthorityFactory::create(dbContext, "EPSG");
diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp
index 4e888f2c..196552d4 100644
--- a/test/unit/test_io.cpp
+++ b/test/unit/test_io.cpp
@@ -6394,6 +6394,37 @@ TEST(wkt_parse, wkt1_oracle) {
// ---------------------------------------------------------------------------
+TEST(wkt_parse, wkt1_lcc_1sp_without_1sp_suffix) {
+ // WKT from Trimble
+ auto wkt = "PROJCS[\"TWM-Madison Co LDP\","
+ "GEOGCS[\"WGS 1984\","
+ "DATUM[\"WGS 1984\","
+ "SPHEROID[\"World Geodetic System 1984\","
+ "6378137,298.257223563]],"
+ "PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],"
+ "UNIT[\"Degree\",0.01745329251994,"
+ "AUTHORITY[\"EPSG\",\"9102\"]],"
+ "AXIS[\"Long\",EAST],AXIS[\"Lat\",NORTH]],"
+ "PROJECTION[\"Lambert_Conformal_Conic\"],"
+ "PARAMETER[\"False_Easting\",103000.0000035],"
+ "PARAMETER[\"False_Northing\",79000.00007055],"
+ "PARAMETER[\"Latitude_Of_Origin\",38.83333333333],"
+ "PARAMETER[\"Central_Meridian\",-89.93333333333],"
+ "PARAMETER[\"Scale_Factor\",1.000019129],"
+ "UNIT[\"Foot_US\",0.3048006096012,AUTHORITY[\"EPSG\",\"9003\"]],"
+ "AXIS[\"East\",EAST],AXIS[\"North\",NORTH]]";
+
+ auto dbContext = DatabaseContext::create();
+ auto obj = WKTParser().attachDatabaseContext(dbContext).createFromWKT(wkt);
+ auto crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj);
+ ASSERT_TRUE(crs != nullptr);
+
+ EXPECT_EQ(crs->derivingConversion()->method()->nameStr(),
+ "Lambert Conic Conformal (1SP)");
+}
+
+// ---------------------------------------------------------------------------
+
TEST(wkt_parse, invalid) {
EXPECT_THROW(WKTParser().createFromWKT(""), ParsingException);
EXPECT_THROW(WKTParser().createFromWKT("A"), ParsingException);
diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp
index f76647e2..0e27aa9b 100644
--- a/test/unit/test_operation.cpp
+++ b/test/unit/test_operation.cpp
@@ -5429,6 +5429,20 @@ TEST(operation, normalizeForVisualization) {
auto authFactory =
AuthorityFactory::create(DatabaseContext::create(), "EPSG");
+ const auto checkThroughWKTRoundtrip = [](const CoordinateOperationNNPtr
+ &opRef) {
+ auto wkt = opRef->exportToWKT(
+ WKTFormatter::create(WKTFormatter::Convention::WKT2_2019).get());
+ auto objFromWkt = WKTParser().createFromWKT(wkt);
+ auto opFromWkt =
+ nn_dynamic_pointer_cast<CoordinateOperation>(objFromWkt);
+ ASSERT_TRUE(opFromWkt != nullptr);
+ EXPECT_TRUE(opRef->_isEquivalentTo(opFromWkt.get()));
+ EXPECT_EQ(
+ opFromWkt->exportToPROJString(PROJStringFormatter::create().get()),
+ opRef->exportToPROJString(PROJStringFormatter::create().get()));
+ };
+
// Source(geographic) must be inverted
{
auto src = authFactory->createCoordinateReferenceSystem("4326");
@@ -5443,6 +5457,7 @@ TEST(operation, normalizeForVisualization) {
"+proj=pipeline "
"+step +proj=unitconvert +xy_in=deg +xy_out=rad "
"+step +proj=utm +zone=31 +ellps=WGS84");
+ checkThroughWKTRoundtrip(opNormalized);
}
// Target(geographic) must be inverted
@@ -5459,6 +5474,7 @@ TEST(operation, normalizeForVisualization) {
"+proj=pipeline "
"+step +inv +proj=utm +zone=31 +ellps=WGS84 "
"+step +proj=unitconvert +xy_in=rad +xy_out=deg");
+ checkThroughWKTRoundtrip(opNormalized);
}
// Source(geographic) and target(projected) must be inverted
@@ -5475,6 +5491,7 @@ TEST(operation, normalizeForVisualization) {
"+proj=pipeline "
"+step +proj=unitconvert +xy_in=deg +xy_out=rad "
"+step +proj=utm +zone=28 +ellps=GRS80");
+ checkThroughWKTRoundtrip(opNormalized);
}
// No inversion