aboutsummaryrefslogtreecommitdiff
path: root/test/cli
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-02-02 22:34:56 +0100
committerEven Rouault <even.rouault@spatialys.com>2020-02-04 21:43:42 +0100
commit87318283eedef680356ef272a6af39ac3140d333 (patch)
treede858fc84d84e0ac6eec8d121ee5f2b76b55e0ea /test/cli
parent42035701c02d15d586e762afa1db5c8b5c9eac39 (diff)
downloadPROJ-87318283eedef680356ef272a6af39ac3140d333.tar.gz
PROJ-87318283eedef680356ef272a6af39ac3140d333.zip
Add projsync utility
Fixes #1750
Diffstat (limited to 'test/cli')
-rw-r--r--test/cli/CMakeLists.txt4
-rw-r--r--test/cli/Makefile.am14
-rwxr-xr-xtest/cli/test_projsync194
3 files changed, 211 insertions, 1 deletions
diff --git a/test/cli/CMakeLists.txt b/test/cli/CMakeLists.txt
index feef5bf0..cf4192d7 100644
--- a/test/cli/CMakeLists.txt
+++ b/test/cli/CMakeLists.txt
@@ -5,6 +5,7 @@ set(CS2CS_BIN "cs2cs")
set(PROJ_BIN "proj")
set(PROJINFO_BIN "projinfo")
set(CCT_BIN "cct")
+set(PROJSYNC_BIN "projsync")
proj_add_test_script_sh("test27" PROJ_BIN)
proj_add_test_script_sh("test83" PROJ_BIN)
proj_add_test_script_sh("testproj" PROJ_BIN)
@@ -14,3 +15,6 @@ proj_add_test_script_sh("testIGNF" CS2CS_BIN "ntf_r93.gsb")
proj_add_test_script_sh("testntv2" CS2CS_BIN "ntv2_0.gsb")
proj_add_test_script_sh("testprojinfo" PROJINFO_BIN)
proj_add_test_script_sh("testcct" CCT_BIN)
+if(BUILD_PROJSYNC_DATA)
+proj_add_test_script_sh("test_projsync" PROJSYNC_BIN)
+endif()
diff --git a/test/cli/Makefile.am b/test/cli/Makefile.am
index 417ec137..7ff42016 100644
--- a/test/cli/Makefile.am
+++ b/test/cli/Makefile.am
@@ -6,6 +6,7 @@ PROJEXE = $(EXEPATH)/proj
CS2CSEXE = $(EXEPATH)/cs2cs
PROJINFOEXE = $(EXEPATH)/projinfo
CCTEXE = $(EXEPATH)/cct
+PROJSYNC_EXE = $(EXEPATH)/projsync
# PROJ.4 test scripts
TEST27 = $(THIS_DIR)/test27
@@ -18,6 +19,7 @@ TESTDATUMFILE = $(THIS_DIR)/testdatumfile
TESTIGN = $(THIS_DIR)/testIGNF
TESTPROJINFO = $(THIS_DIR)/testprojinfo
TESTCCT = $(THIS_DIR)/testcct
+TESTPROJSYNC = $(THIS_DIR)/test_projsync
EXTRA_DIST = pj_out27.dist pj_out83.dist td_out.dist \
test27 test83 tv_out.dist tf_out.dist \
@@ -26,6 +28,7 @@ EXTRA_DIST = pj_out27.dist pj_out83.dist td_out.dist \
testprojinfo testprojinfo_out.dist \
testcct testcct_out.dist \
testproj testproj_out.dist \
+ test_projsync \
CMakeLists.txt
testprojinfo-check:
@@ -61,4 +64,13 @@ testntv2-check:
testcct-check:
PROJ_SKIP_READ_USER_WRITABLE_DIRECTORY=YES PROJ_LIB=$(PROJ_LIB) $(TESTCCT) $(CCTEXE)
-check-local: testprojinfo-check test27-check test83-check testproj-check testvarious-check testdatumfile-check testign-check testntv2-check testcct-check
+
+if HAVE_CURL
+testprojsync-check:
+ PROJ_LIB=$(PROJ_LIB) $(TESTPROJSYNC) $(PROJSYNC_EXE)
+else
+testprojsync-check:
+ echo "Skipping testprojsync-check"
+endif
+
+check-local: testprojinfo-check test27-check test83-check testproj-check testvarious-check testdatumfile-check testign-check testntv2-check testcct-check testprojsync-check
diff --git a/test/cli/test_projsync b/test/cli/test_projsync
new file mode 100755
index 00000000..0292ceaa
--- /dev/null
+++ b/test/cli/test_projsync
@@ -0,0 +1,194 @@
+:
+# Test projsync
+
+TEST_CLI_DIR=`dirname $0`
+EXE=$1
+
+usage()
+{
+ echo "Usage: ${0} <path to 'projsync' program>"
+ echo
+ exit 1
+}
+
+if test -z "${EXE}"; then
+ EXE=../../src/projsync
+fi
+
+if test ! -x ${EXE}; then
+ echo "*** ERROR: Can not find '${EXE}' program!"
+ exit 1
+fi
+
+echo "============================================"
+echo "Running ${0} using ${EXE}:"
+echo "============================================"
+
+if ! curl -s https://cdn.proj.org/files.geojson >/dev/null 2>/dev/null; then
+ if ! wget https://cdn.proj.org/files.geojson -O /dev/null 2>/dev/null; then
+ echo "Cannot download https://cdn.proj.org/files.geojson. Skipping test"
+ exit 0
+ fi
+fi
+
+TMP_OUT=test_projsync_out.txt
+
+rm -rf tmp_user_writable_directory
+mkdir -p tmp_user_writable_directory
+
+echo "Testing $EXE --list-files --target-dir tmp_user_writable_directory"
+if ! $EXE --list-files --target-dir tmp_user_writable_directory > ${TMP_OUT}; then
+ echo "--list-files failed"
+ cat ${TMP_OUT}
+ exit 100
+fi
+cat ${TMP_OUT} | grep "at_bev_README.txt,,at_bev" >/dev/null || (cat ${TMP_OUT}; exit 100)
+
+export PROJ_USER_WRITABLE_DIRECTORY=tmp_user_writable_directory
+
+if test ! -f ${PROJ_USER_WRITABLE_DIRECTORY}/cache.db; then
+ echo "*** ERROR: Can not find ${PROJ_USER_WRITABLE_DIRECTORY}/cache.db!"
+ exit 100
+fi
+if test ! -f ${PROJ_USER_WRITABLE_DIRECTORY}/files.geojson; then
+ echo "*** ERROR: Can not find ${PROJ_USER_WRITABLE_DIRECTORY}/files.geojson!"
+ exit 100
+fi
+
+echo "Testing $EXE --all"
+if ! $EXE --all --dry-run > ${TMP_OUT}; then
+ echo "--all failed"
+ cat ${TMP_OUT}
+ exit 100
+fi
+cat ${TMP_OUT} | grep "Would download https://cdn.proj.org/at_bev_README.txt" >/dev/null || (cat ${TMP_OUT}; exit 100)
+
+
+echo "Testing $EXE --source-id fr_ign"
+if ! $EXE --source-id fr_ign --dry-run > ${TMP_OUT}; then
+ echo "--source-id fr_ign failed"
+ cat ${TMP_OUT}
+ exit 100
+fi
+cat ${TMP_OUT} | grep "fr_ign_README.txt" >/dev/null || (cat ${TMP_OUT}; exit 100)
+
+
+echo "Testing $EXE --source-id non_existing"
+if $EXE --source-id non_existing >${TMP_OUT} 2>&1 ; then
+ echo "--source-id non_existing failed"
+ cat ${TMP_OUT}
+ exit 100
+fi
+cat ${TMP_OUT} | grep "Warning: 'non_existing' is a unknown value for --source-id" >/dev/null || (cat ${TMP_OUT}; exit 100)
+cat ${TMP_OUT} | grep "fr_ign" >/dev/null || (cat ${TMP_OUT}; exit 100)
+
+
+echo "Testing $EXE --area-of-use France"
+if ! $EXE --area-of-use France --dry-run > ${TMP_OUT}; then
+ echo "--area-of-use France failed"
+ cat ${TMP_OUT}
+ exit 100
+fi
+cat ${TMP_OUT} | grep "fr_ign_ntf_r93.tif" >/dev/null || (cat ${TMP_OUT}; exit 100)
+
+
+echo "Testing $EXE --area-of-use non_existing"
+if $EXE --area-of-use non_existing >${TMP_OUT} 2>&1 ; then
+ echo "--area-of-use non_existing failed"
+ cat ${TMP_OUT}
+ exit 100
+fi
+cat ${TMP_OUT} | grep "Warning: 'non_existing' is a unknown value for --area-of-use." >/dev/null || (cat ${TMP_OUT}; exit 100)
+cat ${TMP_OUT} | grep "Australia" >/dev/null || (cat ${TMP_OUT}; exit 100)
+
+
+echo "Testing $EXE --file ntf_r93"
+if ! $EXE --file ntf_r93 > ${TMP_OUT}; then
+ echo "--file ntf_r93 failed"
+ cat ${TMP_OUT}
+ exit 100
+fi
+cat ${TMP_OUT} | grep "Downloading https://cdn.proj.org/fr_ign_ntf_r93.tif" >/dev/null || (cat ${TMP_OUT}; exit 100)
+
+if test ! -f ${PROJ_USER_WRITABLE_DIRECTORY}/fr_ign_ntf_r93.tif; then
+ echo "*** ERROR: Can not find ${PROJ_USER_WRITABLE_DIRECTORY}/fr_ign_ntf_r93.tif!"
+ exit 100
+fi
+
+echo "Testing $EXE --file ntf_r93 a second time"
+if ! $EXE --file ntf_r93 > ${TMP_OUT}; then
+ echo "--file ntf_r93 failed"
+ cat ${TMP_OUT}
+ exit 100
+fi
+cat ${TMP_OUT} | grep "https://cdn.proj.org/fr_ign_ntf_r93.tif already downloaded" >/dev/null || (cat ${TMP_OUT}; exit 100)
+
+rm -f ${PROJ_USER_WRITABLE_DIRECTORY}/fr_ign_ntf_r93.tif
+
+
+echo "Testing $EXE --file non_existing"
+if $EXE --file non_existing >${TMP_OUT} 2>&1 ; then
+ echo "--file non_existing failed"
+ cat ${TMP_OUT}
+ exit 100
+fi
+cat ${TMP_OUT} | grep "Warning: 'non_existing' is a unknown value for --file." >/dev/null || (cat ${TMP_OUT}; exit 100)
+cat ${TMP_OUT} | grep "fr_ign_ntf_r93.tif" >/dev/null || (cat ${TMP_OUT}; exit 100)
+
+
+echo "Testing $EXE --bbox 2,49,3,50"
+if ! $EXE --bbox 2,49,3,50 --dry-run > ${TMP_OUT}; then
+ echo "--bbox 2,49,3,50 failed"
+ cat ${TMP_OUT}
+ exit 100
+fi
+cat ${TMP_OUT} | grep "fr_ign_ntf_r93.tif" >/dev/null || (cat ${TMP_OUT}; exit 100)
+cat ${TMP_OUT} | grep "us_nga_egm96_15.tif" >/dev/null || (cat ${TMP_OUT}; exit 100)
+
+
+echo "Testing $EXE --bbox 2,49,3,50 --exclude-world-coverage"
+if ! $EXE --bbox 2,49,3,50 --exclude-world-coverage --dry-run > ${TMP_OUT}; then
+ echo "--bbox 2,49,3,50 --exclude-world-coverage failed"
+ cat ${TMP_OUT}
+ exit 100
+fi
+cat ${TMP_OUT} | grep "fr_ign_ntf_r93.tif" >/dev/null || (cat ${TMP_OUT}; exit 100)
+if cat ${TMP_OUT} | grep "us_nga_egm96_15.tif" >/dev/null; then
+ cat ${TMP_OUT}
+ exit 100
+fi
+
+
+echo "Testing $EXE --bbox 170,-90,-170,90"
+if ! $EXE --bbox 170,-90,-170,90 --dry-run > ${TMP_OUT}; then
+ echo "--bbox 170,-90,-170,90 failed"
+ cat ${TMP_OUT}
+ exit 100
+fi
+cat ${TMP_OUT} | grep "nz_linz_nzgeoid2009.tif" >/dev/null || (cat ${TMP_OUT}; exit 100)
+cat ${TMP_OUT} | grep "us_noaa_alaska.tif" >/dev/null || (cat ${TMP_OUT}; exit 100)
+
+
+echo "Testing $EXE --bbox 170,-90,190,90"
+if ! $EXE --bbox 170,-90,190,90 --dry-run > ${TMP_OUT}; then
+ echo "--bbox 170,-90,190,90 failed"
+ cat ${TMP_OUT}
+ exit 100
+fi
+cat ${TMP_OUT} | grep "nz_linz_nzgeoid2009.tif" >/dev/null || (cat ${TMP_OUT}; exit 100)
+cat ${TMP_OUT} | grep "us_noaa_alaska.tif" >/dev/null || (cat ${TMP_OUT}; exit 100)
+
+
+echo "Testing $EXE --bbox -190,-90,-170,90"
+if ! $EXE --bbox -190,-90,-170,90 --dry-run > ${TMP_OUT}; then
+ echo "--bbox -190,-90,-170,90 failed"
+ cat ${TMP_OUT}
+ exit 100
+fi
+cat ${TMP_OUT} | grep "nz_linz_nzgeoid2009.tif" >/dev/null || (cat ${TMP_OUT}; exit 100)
+cat ${TMP_OUT} | grep "us_noaa_alaska.tif" >/dev/null || (cat ${TMP_OUT}; exit 100)
+
+rm -rf ${PROJ_USER_WRITABLE_DIRECTORY}
+rm ${TMP_OUT}
+
+exit 0