aboutsummaryrefslogtreecommitdiff
path: root/test/cli/testdatumfile
blob: 3496299f9ef409a231654a390c1730e4c79dedfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
:
# Script to do some testing of various transformations depending on datum
# files that are not always available.
#
#
TEST_CLI_DIR=`dirname $0`
EXE=$1

usage()
{
    echo "Usage: ${0} <path to 'cs2cs' 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

echo "============================================"
echo "Running ${0} using ${EXE}:"
echo "============================================"

mkdir "dir with \" space"
if test -f "${PROJ_LIB}/conus"; then
    cp "${PROJ_LIB}/conus" "dir with \" space/myconus"
else
    cp "`dirname $0`/../../data/conus" "dir with \" space/myconus"
fi

OUT=td_out
#EXE=../src/cs2cs
#
echo "doing tests into file ${OUT}, please wait"
rm -f ${OUT}
#
echo "##############################################################" >> ${OUT}
echo 1st through ntv1, 2nd through conus >> ${OUT}
#
$EXE +proj=latlong +ellps=clrk66 +nadgrids=ntv1_can.dat,conus \
 +to +proj=latlong +datum=NAD83 \
 -E >>${OUT} <<EOF
111d00'00.000"W 44d00'00.000"N 0.0
111d00'00.000"W 39d00'00.000"N 0.0
EOF

echo "##############################################################" >> ${OUT}
echo As above, but without ntv1 everything goes through conus file. >> ${OUT}
#
$EXE +proj=latlong +ellps=clrk66 '+nadgrids="./dir with "" space/myconus"' \
 +to +proj=latlong +datum=NAD83 \
 -E >>${OUT} <<EOF
111d00'00.000"W 44d00'00.000"N 0.0
111d00'00.000"W 39d00'00.000"N 0.0
EOF

echo "##############################################################" >> ${OUT}
echo "Test --bbox -141.01,40.04,-47.74,83.17 NAD27 NAD83 (using NTv2)" >> ${OUT}
$EXE --bbox -141.01,40.04,-47.74,83.17 NAD27 NAD83 >>${OUT} <<EOF
40.5 -60
EOF

echo "##############################################################" >> ${OUT}
echo "Test --area \"USA - CONUS - onshore\" NAD27 NAD83 (using conus)" >> ${OUT}
$EXE --area "USA - CONUS - onshore" NAD27 NAD83 >>${OUT} <<EOF
44 -111
40.5 -60
EOF

echo "##############################################################" >> ${OUT}
echo Test MD used where available >> ${OUT}
#
$EXE +proj=latlong +ellps=clrk66 +nadgrids=MD,conus \
 +to +proj=latlong +datum=NAD83 \
 -E >>${OUT} <<EOF
79d58'00.000"W 37d02'00.000"N 0.0
79d58'00.000"W 36d58'00.000"N 0.0
EOF
#
$EXE +proj=latlong +ellps=clrk66 +nadgrids=conus \
 +to +proj=latlong +datum=NAD83 \
 -E >>${OUT} <<EOF
79d58'00.000"W 37d02'00.000"N 0.0
79d58'00.000"W 36d58'00.000"N 0.0
EOF
#
echo "##############################################################" >> ${OUT}
echo "Test that we use grid shift files even if we are right on the" >> ${OUT}
echo "edge or even a wee bit outside (#141)."  >> ${OUT}
#
# Our test points are (1) right on mesh corner, (2) outside but within 
# epsilon (3) inside a bit (4) outside by more than epsilon
#
$EXE +proj=latlong +ellps=WGS84 +nadgrids=ntf_r93.gsb,null \
 +to +proj=latlong +datum=WGS84 \
 -E -f "%.12f" >>${OUT} <<EOF
-5.5 52.0
-5.5000000000001 52.0000000000001
-5.4999 51.9999
-5.5001 52.0
EOF
#
$EXE +proj=latlong +datum=WGS84 \
 +to +proj=latlong +ellps=WGS84 +nadgrids=ntf_r93.gsb,null \
 -E -f "%.12f" >>${OUT} <<EOF
-5.5 52.0
-5.5000000000001 52.0000000000001
-5.4999 51.9999
-5.5001 52.0
EOF
#
echo "##############################################################" >> ${OUT}
echo "NAD27 -> NAD83: 1st through ntv1 or ntv2, 2nd through conus" >> ${OUT}
#
$EXE NAD27 NAD83 -E -f "%.4f" >>${OUT} <<EOF
55d00'00.000"N 111d00'00.000"W 0.0
39d00'00.000"N 111d00'00.000"W 0.0
EOF

#
echo "##############################################################" >> ${OUT}
echo "WGS84 (2D) -> WGS84+EGM96" >> ${OUT}
#
$EXE +init=epsg:4326 +to +init=epsg:4326 +geoidgrids=egm96_15.gtx -E >>${OUT} <<EOF
2dE 49dN 0
EOF

#
echo "##############################################################" >> ${OUT}
echo "WGS84 (3D) -> WGS84+EGM96" >> ${OUT}
#
$EXE +init=epsg:4979 +to +init=epsg:4326 +geoidgrids=egm96_15.gtx -E >>${OUT} <<EOF
2dE 49dN 0
EOF

#
echo "##############################################################" >> ${OUT}
echo "WGS84 (2D), promoted to 3D -> WGS84+EGM96" >> ${OUT}
#
$EXE --3d +init=epsg:4326 +to +init=epsg:4326 +geoidgrids=egm96_15.gtx -E >>${OUT} <<EOF
2dE 49dN 0
EOF

# Cleanup
rm -rf "dir with \" space"

#
##############################################################################
# Done!     
# do 'diff' with distribution results
echo "diff ${OUT} with ${OUT}.dist"
diff -u -b ${OUT} ${TEST_CLI_DIR}/${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