aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2019-01-04 19:13:01 +0100
committerGitHub <noreply@github.com>2019-01-04 19:13:01 +0100
commit3ea468222fdabdae3aa5b47439d6b3bfb0a93c8e (patch)
tree7a8bc721676f8df2c3a7e7cdf05387300e03584b /test
parentd89a6ab2f3f26d1451971369b0ccfc4eb322729d (diff)
parentedb068401822c0cb7047019ae7a1dac587778ce3 (diff)
downloadPROJ-3ea468222fdabdae3aa5b47439d6b3bfb0a93c8e.tar.gz
PROJ-3ea468222fdabdae3aa5b47439d6b3bfb0a93c8e.zip
Merge pull request #1205 from kbevers/master
Better handling of pipelines including step with PJ_IO_UNITS_WHATEVER operations
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt1
-rw-r--r--test/gie/unitconvert.gie2
-rw-r--r--test/unit/CMakeLists.txt7
-rw-r--r--test/unit/Makefile.am9
-rw-r--r--test/unit/proj_angular_io_test.cpp101
5 files changed, 118 insertions, 2 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index c46ad5d7..b618091b 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -9,6 +9,7 @@ proj_add_gie_test("Ellipsoid" "gie/ellipsoid.gie")
proj_add_gie_test("GDA" "gie/GDA.gie")
proj_add_gie_test("4D-API-cs2cs-style" "gie/4D-API_cs2cs-style.gie")
proj_add_gie_test("DHDN_ETRS89" "gie/DHDN_ETRS89.gie")
+proj_add_gie_test("Unitconvert" "gie/unitconvert.gie")
# GIGS tests. Uncommented tests are expected to fail due to issues with
# various projections. Should be investigated further and fixed.
diff --git a/test/gie/unitconvert.gie b/test/gie/unitconvert.gie
index 7bbea49d..2a56ba59 100644
--- a/test/gie/unitconvert.gie
+++ b/test/gie/unitconvert.gie
@@ -28,7 +28,7 @@ expect 0.5 0.5 1 1
operation proj=unitconvert xy_in=deg xy_out=rad
tolerance 0.000000000001
accept 1 1 1 1
-expect 0.017453292519943296 0.017453292519943296 1 1
+expect 1 1 1 1 # gie does a rad->deg conversion behind the scenes
operation proj=unitconvert xy_in=grad xy_out=deg
tolerance 0.000000000001
diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt
index 68a6e60f..09405147 100644
--- a/test/unit/CMakeLists.txt
+++ b/test/unit/CMakeLists.txt
@@ -74,6 +74,13 @@ target_link_libraries(proj_errno_string_test
${PROJ_LIBRARIES})
add_test(NAME proj_errno_string_test COMMAND proj_errno_string_test)
+add_executable(proj_angular_io_test
+ main.cpp
+ proj_angular_io_test.cpp)
+target_link_libraries(proj_angular_io_test
+ gtest
+ ${PROJ_LIBRARIES})
+add_test(NAME proj_angular_io_test COMMAND proj_angular_io_test)
if (MSVC AND BUILD_LIBPROJ_SHARED)
# ph_phi2_test not compatible of a .dll build
diff --git a/test/unit/Makefile.am b/test/unit/Makefile.am
index f26e355d..e6d95e9c 100644
--- a/test/unit/Makefile.am
+++ b/test/unit/Makefile.am
@@ -12,6 +12,7 @@ PROJ_LIB ?= ../../data
noinst_PROGRAMS = pj_transform_test
noinst_PROGRAMS += pj_phi2_test
noinst_PROGRAMS += proj_errno_string_test
+noinst_PROGRAMS += proj_angular_io_test
noinst_PROGRAMS += test_cpp_api
noinst_PROGRAMS += gie_self_tests
noinst_PROGRAMS += include_proj_h_from_c
@@ -34,6 +35,12 @@ proj_errno_string_test_LDADD= ../../src/libproj.la ../../test/googletest/libgtes
proj_errno_string_test-check: proj_errno_string_test
./proj_errno_string_test
+proj_angular_io_test_SOURCES = proj_angular_io_test.cpp main.cpp
+proj_angular_io_test_LDADD = ../../src/libproj.la ../../test/googletest/libgtest.la
+
+proj_angular_io_test-check: proj_angular_io_test
+ ./proj_angular_io_test
+
test_cpp_api_SOURCES = test_util.cpp test_common.cpp test_crs.cpp test_metadata.cpp test_io.cpp test_operation.cpp test_datum.cpp test_factory.cpp test_c_api.cpp main.cpp
test_cpp_api_LDADD = ../../src/libproj.la ../../test/googletest/libgtest.la @SQLITE3_LDFLAGS@
@@ -48,4 +55,4 @@ gie_self_tests-check: gie_self_tests
include_proj_h_from_c_SOURCES = include_proj_h_from_c.c
-check-local: pj_transform_test-check pj_phi2_test-check proj_errno_string_test-check test_cpp_api-check gie_self_tests-check
+check-local: pj_transform_test-check pj_phi2_test-check proj_errno_string_test-check proj_angular_io_test-check test_cpp_api-check gie_self_tests-check
diff --git a/test/unit/proj_angular_io_test.cpp b/test/unit/proj_angular_io_test.cpp
new file mode 100644
index 00000000..fdb44704
--- /dev/null
+++ b/test/unit/proj_angular_io_test.cpp
@@ -0,0 +1,101 @@
+/******************************************************************************
+ *
+ * Project: PROJ
+ * Purpose: Test that in- and output units behave correctly, especially
+ * angular units that need special treatment.
+ * Author: Kristian Evers <kristianevers@gmail.com>
+ *
+ ******************************************************************************
+ * Copyright (c) 2019, Kristian Evers
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ ****************************************************************************/
+
+#include "proj.h"
+
+#include "gtest_include.h"
+
+namespace {
+
+TEST(AngularUnits, Basic) {
+ auto ctx = proj_context_create();
+ auto P = proj_create(ctx, "proj=latlong");
+
+ EXPECT_TRUE(proj_angular_input(P, PJ_FWD));
+ EXPECT_TRUE(proj_angular_output(P, PJ_FWD));
+ EXPECT_TRUE(proj_angular_input(P, PJ_INV));
+ EXPECT_TRUE(proj_angular_output(P, PJ_INV));
+
+ proj_destroy(P);
+ proj_context_destroy(ctx);
+}
+
+TEST(AngularUnits, Pipelines) {
+ auto ctx = proj_context_create();
+ auto P = proj_create(ctx, "proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=latlong +step +proj=axisswap +order=2,1");
+
+ EXPECT_TRUE(proj_angular_input(P, PJ_FWD));
+ EXPECT_TRUE(proj_angular_output(P, PJ_FWD));
+ EXPECT_TRUE(proj_angular_input(P, PJ_INV));
+ EXPECT_TRUE(proj_angular_output(P, PJ_INV));
+
+ proj_destroy(P);
+ proj_context_destroy(ctx);
+
+}
+
+TEST(AngularUnits, Pipelines2) {
+ auto ctx = proj_context_create();
+ auto P = proj_create(
+ ctx,
+ "+proj=pipeline "
+ "+step +proj=axisswap +order=2,1 "
+ "+step +proj=unitconvert +xy_in=deg +xy_out=rad "
+ "+step +proj=tmerc +lat_0=0 +lon_0=-81 +k=0.9996 +x_0=500000.001016002 +y_0=0 +ellps=WGS84 "
+ "+step +proj=axisswap +order=2,1 "
+ "+step +proj=unitconvert +xy_in=m +z_in=m +xy_out=us-ft +z_out=us-ft");
+
+ EXPECT_FALSE(proj_angular_input(P, PJ_FWD));
+ EXPECT_FALSE(proj_angular_output(P, PJ_FWD));
+
+ proj_destroy(P);
+ proj_context_destroy(ctx);
+
+}
+
+TEST(AngularUnits, Pipelines3) {
+ auto ctx = proj_context_create();
+ auto P = proj_create(
+ ctx,
+ "+proj=pipeline "
+ "+step +proj=axisswap +order=2,1 "
+ "+step +proj=tmerc +lat_0=0 +lon_0=-81 +k=0.9996 +x_0=500000.001016002 +y_0=0 +ellps=WGS84 "
+ "+step +proj=axisswap +order=2,1 "
+ "+step +proj=unitconvert +xy_in=m +z_in=m +xy_out=us-ft +z_out=us-ft");
+
+ EXPECT_TRUE(proj_angular_input(P, PJ_FWD));
+ EXPECT_FALSE(proj_angular_output(P, PJ_FWD));
+
+ proj_destroy(P);
+ proj_context_destroy(ctx);
+
+}
+
+
+} // namespace