aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/apps/proj.cpp8
-rw-r--r--src/transform.cpp16
-rw-r--r--test/cli/CMakeLists.txt1
-rw-r--r--test/cli/Makefile.am7
-rwxr-xr-xtest/cli/testproj55
-rw-r--r--test/cli/testproj_out.dist1
-rw-r--r--test/unit/pj_transform_test.cpp34
7 files changed, 121 insertions, 1 deletions
diff --git a/src/apps/proj.cpp b/src/apps/proj.cpp
index 7fe08023..09c8a81d 100644
--- a/src/apps/proj.cpp
+++ b/src/apps/proj.cpp
@@ -490,6 +490,14 @@ int main(int argc, char **argv) {
exit(0);
}
+ // Ugly hack. See https://github.com/OSGeo/PROJ/issues/1782
+ if( Proj->right == PJ_IO_UNITS_WHATEVER && Proj->descr &&
+ strncmp(Proj->descr, "General Oblique Transformation",
+ strlen("General Oblique Transformation")) == 0 )
+ {
+ Proj->right = PJ_IO_UNITS_PROJECTED;
+ }
+
if (inverse) {
if (!Proj->inv)
emess(3,"inverse projection not available");
diff --git a/src/transform.cpp b/src/transform.cpp
index d111d835..781c0061 100644
--- a/src/transform.cpp
+++ b/src/transform.cpp
@@ -231,6 +231,14 @@ static int geographic_to_projected (PJ *P, long n, int dist, double *x, double *
return 0;
}
+ // Ugly hack. See https://github.com/OSGeo/PROJ/issues/1782
+ if( P->right == PJ_IO_UNITS_WHATEVER && P->descr &&
+ strncmp(P->descr, "General Oblique Transformation",
+ strlen("General Oblique Transformation")) == 0 )
+ {
+ P->right = PJ_IO_UNITS_PROJECTED;
+ }
+
for( i = 0; i <n; i++ )
{
PJ_XY projected_loc;
@@ -342,6 +350,14 @@ static int projected_to_geographic (PJ *P, long n, int dist, double *x, double *
return 0;
}
+ // Ugly hack. See https://github.com/OSGeo/PROJ/issues/1782
+ if( P->right == PJ_IO_UNITS_WHATEVER && P->descr &&
+ strncmp(P->descr, "General Oblique Transformation",
+ strlen("General Oblique Transformation")) == 0 )
+ {
+ P->right = PJ_IO_UNITS_PROJECTED;
+ }
+
/* Fallback to the original PROJ.4 API 2d inversion - inv */
for( i = 0; i < n; i++ ) {
PJ_XY projected_loc;
diff --git a/test/cli/CMakeLists.txt b/test/cli/CMakeLists.txt
index 4e1ab75a..feef5bf0 100644
--- a/test/cli/CMakeLists.txt
+++ b/test/cli/CMakeLists.txt
@@ -7,6 +7,7 @@ set(PROJINFO_BIN "projinfo")
set(CCT_BIN "cct")
proj_add_test_script_sh("test27" PROJ_BIN)
proj_add_test_script_sh("test83" PROJ_BIN)
+proj_add_test_script_sh("testproj" PROJ_BIN)
proj_add_test_script_sh("testvarious" CS2CS_BIN)
proj_add_test_script_sh("testdatumfile" CS2CS_BIN "connu")
proj_add_test_script_sh("testIGNF" CS2CS_BIN "ntf_r93.gsb")
diff --git a/test/cli/Makefile.am b/test/cli/Makefile.am
index 758352c6..fb7169e4 100644
--- a/test/cli/Makefile.am
+++ b/test/cli/Makefile.am
@@ -10,6 +10,7 @@ CCTEXE = $(EXEPATH)/cct
# PROJ.4 test scripts
TEST27 = $(THIS_DIR)/test27
TEST83 = $(THIS_DIR)/test83
+TESTPROJ = $(THIS_DIR)/testproj
TESTNTV2 = $(THIS_DIR)/testntv2
TESTVARIOUS = $(THIS_DIR)/testvarious
TESTFLAKY = $(THIS_DIR)/testflaky
@@ -24,6 +25,7 @@ EXTRA_DIST = pj_out27.dist pj_out83.dist td_out.dist \
testIGNF proj_outIGNF.dist \
testprojinfo testprojinfo_out.dist \
testcct testcct_out.dist \
+ testproj testproj_out.dist \
CMakeLists.txt
testprojinfo-check:
@@ -35,6 +37,9 @@ test27-check:
test83-check:
$(TEST83) $(PROJEXE)
+testproj-check:
+ $(TESTPROJ) $(PROJEXE)
+
testvarious-check:
PROJ_LIB=$(PROJ_LIB) $(TESTVARIOUS) $(CS2CSEXE)
@@ -56,4 +61,4 @@ testntv2-check:
testcct-check:
PROJ_LIB=$(PROJ_LIB) $(TESTCCT) $(CCTEXE)
-check-local: testprojinfo-check test27-check test83-check testvarious-check testdatumfile-check testign-check testntv2-check testcct-check
+check-local: testprojinfo-check test27-check test83-check testproj-check testvarious-check testdatumfile-check testign-check testntv2-check testcct-check
diff --git a/test/cli/testproj b/test/cli/testproj
new file mode 100755
index 00000000..8686224e
--- /dev/null
+++ b/test/cli/testproj
@@ -0,0 +1,55 @@
+:
+# Script to test proj exe
+#
+TEST_CLI_DIR=`dirname $0`
+EXE=$1
+
+usage()
+{
+ echo "Usage: ${0} <path to 'proj' program>"
+ echo
+ exit 1
+}
+
+if test -z "${EXE}"; then
+ EXE=../../src/cs2cs
+fi
+
+if test ! -x ${EXE}; then
+ echo "*** ERROR: Can not find '${EXE}' program!"
+ exit 1
+fi
+
+if test -z "${PROJ_LIB}"; then
+ export PROJ_LIB="`dirname $0`/../../data"
+fi
+
+echo "============================================"
+echo "Running ${0} using ${EXE}:"
+echo "============================================"
+
+OUT=testproj_out
+#
+echo "doing tests into file ${OUT}, please wait"
+#
+$EXE +ellps=WGS84 +proj=ob_tran +o_proj=latlon +o_lon_p=0.0 +o_lat_p=90.0 +lon_0=360.0 +to_meter=0.0174532925199433 +no_defs -E -f '%.3f' >${OUT} <<EOF
+2 49
+EOF
+
+#
+# do 'diff' with distribution results
+echo "diff ${OUT} with testproj_out.dist"
+diff -u -b ${OUT} ${TEST_CLI_DIR}/testproj_out.dist
+if [ $? -ne 0 ] ; then
+ echo ""
+ echo "PROBLEMS HAVE OCCURRED"
+ echo "test file ${OUT} saved"
+ echo
+ exit 100
+else
+ echo "TEST OK"
+ echo "test file ${OUT} removed"
+ echo
+ /bin/rm -f ${OUT}
+ exit 0
+fi
diff --git a/test/cli/testproj_out.dist b/test/cli/testproj_out.dist
new file mode 100644
index 00000000..fad0a014
--- /dev/null
+++ b/test/cli/testproj_out.dist
@@ -0,0 +1 @@
+2 49 2.000 49.000
diff --git a/test/unit/pj_transform_test.cpp b/test/unit/pj_transform_test.cpp
index b3a061b4..1f4473c1 100644
--- a/test/unit/pj_transform_test.cpp
+++ b/test/unit/pj_transform_test.cpp
@@ -614,4 +614,38 @@ TEST(proj_api_h, pj_set_finder) {
pj_set_finder(nullptr);
}
+// ---------------------------------------------------------------------------
+
+TEST(pj_transform_test, ob_tran_to_meter_as_dest) {
+ auto src = pj_init_plus(
+ "+ellps=WGS84 +a=57.29577951308232 +proj=eqc +lon_0=0.0 +no_defs");
+ auto dst = pj_init_plus("+ellps=WGS84 +proj=ob_tran +o_proj=latlon "
+ "+o_lon_p=0.0 +o_lat_p=90.0 +lon_0=360.0 "
+ "+to_meter=0.0174532925199433 +no_defs");
+ double x = 2 * DEG_TO_RAD;
+ double y = 49 * DEG_TO_RAD;
+ EXPECT_EQ(pj_transform(src, dst, 1, 0, &x, &y, nullptr), 0);
+ EXPECT_NEAR(x, 2 * DEG_TO_RAD, 1e-12) << x / DEG_TO_RAD;
+ EXPECT_NEAR(y, 49 * DEG_TO_RAD, 1e-12) << y / DEG_TO_RAD;
+ pj_free(src);
+ pj_free(dst);
+}
+
+// ---------------------------------------------------------------------------
+
+TEST(pj_transform_test, ob_tran_to_meter_as_srouce) {
+ auto src = pj_init_plus("+ellps=WGS84 +proj=ob_tran +o_proj=latlon "
+ "+o_lon_p=0.0 +o_lat_p=90.0 +lon_0=360.0 "
+ "+to_meter=0.0174532925199433 +no_defs");
+ auto dst = pj_init_plus(
+ "+ellps=WGS84 +a=57.29577951308232 +proj=eqc +lon_0=0.0 +no_defs");
+ double x = 2 * DEG_TO_RAD;
+ double y = 49 * DEG_TO_RAD;
+ EXPECT_EQ(pj_transform(src, dst, 1, 0, &x, &y, nullptr), 0);
+ EXPECT_NEAR(x, 2 * DEG_TO_RAD, 1e-12) << x / DEG_TO_RAD;
+ EXPECT_NEAR(y, 49 * DEG_TO_RAD, 1e-12) << y / DEG_TO_RAD;
+ pj_free(src);
+ pj_free(dst);
+}
+
} // namespace