aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2019-02-11 23:58:16 +0100
committerGitHub <noreply@github.com>2019-02-11 23:58:16 +0100
commit5141b3908e59a26c9fe66de94bb7388bff741b58 (patch)
tree9cf9a136c9dd72e2732ed38470b6c84b558f4b73 /test
parent593fcc4b57d0f5c3a46134add142ee8d9316aec6 (diff)
downloadPROJ-5141b3908e59a26c9fe66de94bb7388bff741b58.tar.gz
PROJ-5141b3908e59a26c9fe66de94bb7388bff741b58.zip
Make tmerc an alias for etmerc. (#1234)
* Make tmerc an alias for etmerc This switches the algorithm used in tmerc to the Poder/Engsager tmerc algorithm. The original tmerc algorithm of Evenden/Snyder origin can still be accessed by adding the +approx flag when initializing a tmerc projection. The +approx flag can also be used when initializing UTM projections, in which case the Evenden/Snyder algorithm is used as well. If a tmerc projection is instantiated on a spherical earth the Evenden/Snyder algorithm is used as well since the Poder/Engsager algorithm is only defined on the ellipsoid. +proj=etmerc can still be instantiated for backwards compatibility reasons. Co-authored-by: Kristian Evers <kristianevers@gmail.com> Co-authored-by: Even Rouault <even.rouault@spatialys.com>
Diffstat (limited to 'test')
-rwxr-xr-xtest/cli/testvarious4
-rw-r--r--test/cli/tv_out.dist2
-rw-r--r--test/gie/builtins.gie10
-rw-r--r--test/unit/test_c_api.cpp21
-rw-r--r--test/unit/test_io.cpp31
-rw-r--r--test/unit/test_operation.cpp16
6 files changed, 53 insertions, 31 deletions
diff --git a/test/cli/testvarious b/test/cli/testvarious
index 7ec50bb3..c1fa61df 100755
--- a/test/cli/testvarious
+++ b/test/cli/testvarious
@@ -239,7 +239,7 @@ EOF
echo "##############################################################" >> ${OUT}
echo "Test transverse mercator (#97)" >> ${OUT}
#
-$EXE +proj=tmerc +k=0.998 +lon_0=-20 +datum=WGS84 +x_0=10000 +y_0=20000 \
+$EXE +proj=tmerc +approx +k=0.998 +lon_0=-20 +datum=WGS84 +x_0=10000 +y_0=20000 \
+to +proj=latlong +datum=WGS84 \
-E >>${OUT} <<EOF
10000 20000
@@ -253,7 +253,7 @@ echo "##############################################################" >> ${OUT}
echo "Test transverse mercator inverse (#97)" >> ${OUT}
#
$EXE +proj=latlong +datum=WGS84 \
- +to +proj=tmerc +k=0.998 +lon_0=-20 +datum=WGS84 +x_0=10000 +y_0=20000 \
+ +to +proj=tmerc +approx +k=0.998 +lon_0=-20 +datum=WGS84 +x_0=10000 +y_0=20000 \
-E >>${OUT} <<EOF
0dN 0.000
15d22'16.108"W 17d52'53.478"N 0.000
diff --git a/test/cli/tv_out.dist b/test/cli/tv_out.dist
index 148d413d..72e95634 100644
--- a/test/cli/tv_out.dist
+++ b/test/cli/tv_out.dist
@@ -352,7 +352,7 @@ Test inverse handling
10 20 -1384841.19 7581707.88 0.00
##############################################################
Test MGI datum gives expected results (#207)
-16.33 48.20 595710.3732102 5357598.4645755 -44.4951085
+16.33 48.20 595710.3731286 5357598.4645652 -44.4951085
##############################################################
Test omerc sensitivity with locations 90d from origin(#114)
56.958381652832 72.8798 -9985.16336453 -227.67701050 0.00000000
diff --git a/test/gie/builtins.gie b/test/gie/builtins.gie
index 82222210..930ca71f 100644
--- a/test/gie/builtins.gie
+++ b/test/gie/builtins.gie
@@ -5218,6 +5218,16 @@ accept -200 -100
expect -7.490535682 -0.000901935
+operation +proj=utm +zone=32
+tolerance 0.001 mm
+accept 12 56 0 2000
+expect 687071.43910944 6210141.32674801 0.00000000 2000.0000
+
+operation +proj=utm +zone=32 +approx
+tolerance 0.001 mm
+accept 12 56 0 2000
+expect 687071.43911000 6210141.32675053 0.00000000 2000.0000
+
===============================================================================
van der Grinten (I)
Misc Sph
diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp
index 8ef426ac..d535e412 100644
--- a/test/unit/test_c_api.cpp
+++ b/test/unit/test_c_api.cpp
@@ -507,36 +507,21 @@ TEST_F(CApi, proj_as_proj_string_incompatible_WKT1) {
// ---------------------------------------------------------------------------
-TEST_F(CApi, proj_as_proj_string_etmerc_option_yes) {
+TEST_F(CApi, proj_as_proj_string_approx_tmerc_option_yes) {
auto obj = proj_create(m_ctxt, "+proj=tmerc +type=crs");
ObjectKeeper keeper(obj);
ASSERT_NE(obj, nullptr);
- const char *options[] = {"USE_ETMERC=YES", nullptr};
+ const char *options[] = {"USE_APPROX_TMERC=YES", nullptr};
auto str = proj_as_proj_string(m_ctxt, obj, PJ_PROJ_4, options);
ASSERT_NE(str, nullptr);
EXPECT_EQ(str,
- std::string("+proj=etmerc +lat_0=0 +lon_0=0 +k=1 +x_0=0 "
+ std::string("+proj=tmerc +approx +lat_0=0 +lon_0=0 +k=1 +x_0=0 "
"+y_0=0 +datum=WGS84 +units=m +no_defs +type=crs"));
}
// ---------------------------------------------------------------------------
-TEST_F(CApi, proj_as_proj_string_etmerc_option_no) {
- auto obj = proj_create(m_ctxt, "+proj=utm +zone=31 +type=crs");
- ObjectKeeper keeper(obj);
- ASSERT_NE(obj, nullptr);
-
- const char *options[] = {"USE_ETMERC=NO", nullptr};
- auto str = proj_as_proj_string(m_ctxt, obj, PJ_PROJ_4, options);
- ASSERT_NE(str, nullptr);
- EXPECT_EQ(str, std::string("+proj=tmerc +lat_0=0 +lon_0=3 +k=0.9996 "
- "+x_0=500000 +y_0=0 +datum=WGS84 +units=m "
- "+no_defs +type=crs"));
-}
-
-// ---------------------------------------------------------------------------
-
TEST_F(CApi, proj_crs_create_bound_crs_to_WGS84) {
auto crs = proj_create_from_database(m_ctxt, "EPSG", "3844",
PJ_CATEGORY_CRS, false, nullptr);
diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp
index 69ef9073..3cb50352 100644
--- a/test/unit/test_io.cpp
+++ b/test/unit/test_io.cpp
@@ -7654,12 +7654,39 @@ TEST(io, projparse_etmerc) {
crs->exportToPROJString(
PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_4)
.get()),
- "+proj=etmerc +lat_0=0 +lon_0=0 +k=1 +x_0=0 +y_0=0 "
+ "+proj=tmerc +lat_0=0 +lon_0=0 +k=1 +x_0=0 +y_0=0 "
"+datum=WGS84 +units=m +no_defs +type=crs");
auto wkt1 = crs->exportToWKT(
WKTFormatter::create(WKTFormatter::Convention::WKT1_GDAL).get());
- EXPECT_TRUE(wkt1.find("EXTENSION[\"PROJ4\",\"+proj=etmerc +lat_0=0 "
+ EXPECT_TRUE(wkt1.find("EXTENSION[\"PROJ4\"") == std::string::npos)
+ << wkt1;
+}
+
+// ---------------------------------------------------------------------------
+
+TEST(io, projparse_tmerc_approx) {
+ auto obj =
+ PROJStringParser().createFromPROJString("+proj=tmerc +approx +type=crs");
+ auto crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj);
+ ASSERT_TRUE(crs != nullptr);
+ auto wkt2 = crs->exportToWKT(
+ &WKTFormatter::create()->simulCurNodeHasId().setMultiLine(false));
+ EXPECT_TRUE(
+ wkt2.find("METHOD[\"Transverse Mercator\",ID[\"EPSG\",9807]]") !=
+ std::string::npos)
+ << wkt2;
+
+ EXPECT_EQ(
+ crs->exportToPROJString(
+ PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_4)
+ .get()),
+ "+proj=tmerc +approx +lat_0=0 +lon_0=0 +k=1 +x_0=0 +y_0=0 "
+ "+datum=WGS84 +units=m +no_defs +type=crs");
+
+ auto wkt1 = crs->exportToWKT(
+ WKTFormatter::create(WKTFormatter::Convention::WKT1_GDAL).get());
+ EXPECT_TRUE(wkt1.find("EXTENSION[\"PROJ4\",\"+proj=tmerc +approx +lat_0=0 "
"+lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m "
"+no_defs\"]") != std::string::npos)
<< wkt1;
diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp
index 6c1ecf1c..586226e2 100644
--- a/test/unit/test_operation.cpp
+++ b/test/unit/test_operation.cpp
@@ -1237,9 +1237,9 @@ TEST(operation, tmerc_export) {
{
auto formatter = PROJStringFormatter::create();
- formatter->setUseETMercForTMerc(true);
+ formatter->setUseApproxTMerc(true);
EXPECT_EQ(conv->exportToPROJString(formatter.get()),
- "+proj=etmerc +lat_0=1 +lon_0=2 +k=3 +x_0=4 +y_0=5");
+ "+proj=tmerc +approx +lat_0=1 +lon_0=2 +k=3 +x_0=4 +y_0=5");
}
EXPECT_EQ(conv->exportToWKT(WKTFormatter::create().get()),
@@ -6061,21 +6061,21 @@ TEST(operation, compoundCRS_to_compoundCRS_with_vertical_transform) {
"+ellps=WGS84");
{
auto formatter = PROJStringFormatter::create();
- formatter->setUseETMercForTMerc(true);
+ formatter->setUseApproxTMerc(true);
EXPECT_EQ(op->exportToPROJString(formatter.get()),
- "+proj=pipeline +step +inv +proj=etmerc +lat_0=1 +lon_0=2 "
+ "+proj=pipeline +step +inv +proj=tmerc +approx +lat_0=1 +lon_0=2 "
"+k=3 +x_0=4 +y_0=5 +ellps=WGS84 +step "
"+proj=vgridshift +grids=bla.gtx +multiplier=0.001 +step "
- "+proj=utm +zone=32 "
+ "+proj=utm +approx +zone=32 "
"+ellps=WGS84");
}
{
auto formatter = PROJStringFormatter::create();
- formatter->setUseETMercForTMerc(true);
+ formatter->setUseApproxTMerc(true);
EXPECT_EQ(op->inverse()->exportToPROJString(formatter.get()),
- "+proj=pipeline +step +inv +proj=utm +zone=32 +ellps=WGS84 "
+ "+proj=pipeline +step +inv +proj=utm +approx +zone=32 +ellps=WGS84 "
"+step +inv +proj=vgridshift +grids=bla.gtx "
- "+multiplier=0.001 +step +proj=etmerc +lat_0=1 +lon_0=2 "
+ "+multiplier=0.001 +step +proj=tmerc +approx +lat_0=1 +lon_0=2 "
"+k=3 +x_0=4 +y_0=5 +ellps=WGS84");
}