Skip to content

Commit

Permalink
Merge 2c3a7c8 into 29474bd
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Dec 10, 2019
2 parents 29474bd + 2c3a7c8 commit a497bca
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/apps/proj.cpp
Expand Up @@ -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");
Expand Down
16 changes: 16 additions & 0 deletions src/transform.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions test/cli/CMakeLists.txt
Expand Up @@ -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")
Expand Down
7 changes: 6 additions & 1 deletion test/cli/Makefile.am
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -35,6 +37,9 @@ test27-check:
test83-check:
$(TEST83) $(PROJEXE)

testproj-check:
$(TESTPROJ) $(PROJEXE)

testvarious-check:
PROJ_LIB=$(PROJ_LIB) $(TESTVARIOUS) $(CS2CSEXE)

Expand All @@ -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
55 changes: 55 additions & 0 deletions 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
1 change: 1 addition & 0 deletions test/cli/testproj_out.dist
@@ -0,0 +1 @@
2 49 2.000 49.000
34 changes: 34 additions & 0 deletions test/unit/pj_transform_test.cpp
Expand Up @@ -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

0 comments on commit a497bca

Please sign in to comment.