-
Notifications
You must be signed in to change notification settings - Fork 803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use same arguments to printf format string for both radians and degre… #2453
Conversation
…es in output by cct Currently the output of the cct utility is different between radians and degrees (as expected by cct), because of a bug in cct: $ printf "1 2\n" | cct -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad 1.0000000000 2.0000000000 0.0000 0.0000 $ printf "1 2\n" | cct -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=deg 1.0000 2.0000 0.0000 0.0000 The arguments to the printf format string are as follows: * radians: width 14, precision 10 * degrees: width 13, precision 4 (this is by mistake. bug!) After the suggested fix has been applied, output will be the same for both radians and degrees: $ printf "1 2\n" | cct -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad 1.0000000000 2.0000000000 0.0000 0.0000 $ printf "1 2\n" | cct -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=deg 1.0000000000 2.0000000000 0.0000 0.0000 The cause of the bug is that cct does test if it "has radians to output", but "neglects" to test if it "has degrees to output", resulting in using different arguments to the printf format string in the latter case. The fix makes cct test if it "has either radians or degrees to output". Verified against v7.2.0
would you mind adding a test case in test/cli/testcct and test/cli/testcct_out.dist ? |
On 2020-11-27 19:15, Even Rouault wrote:
would you mind adding a test case in test/cli/testcct and
test/cli/testcct_out.dist ?
Never done this before ...
Please advice.
I have modified the files and attached them to this message.
(testcct and testcct_out.dist)
Hopefully, github.com will not spill my effort by refusing
them at their side.
When I invoke the modified test, the result is as follows:
@@(proj7) ./testcct $(which cct)
============================================
Running ./testcct using /opt/proj7/usr/bin/cct:
============================================
diff testcct_out with testcct_out.dist
TEST OK
test file testcct_out removed
Regards,
Henri
:
# Test cct
TEST_CLI_DIR=`dirname $0`
EXE=$1
usage()
{
echo "Usage: ${0} <path to 'cct' program>"
echo
exit 1
}
if test -z "${EXE}"; then
EXE=../../src/cct
fi
if test ! -x ${EXE}; then
echo "*** ERROR: Can not find '${EXE}' program!"
exit 1
fi
echo "============================================"
echo "Running ${0} using ${EXE}:"
echo "============================================"
OUT=testcct_out
rm -f ${OUT}
echo "Testing cct -d 8 +proj=merc +R=1" >> ${OUT}
echo "90 45" 0 | $EXE -d 8 +proj=merc +R=1 >>${OUT}
echo "" >>${OUT}
# tests without specifying the number of decimals (by default: 8 for radians and degrees, 4 for meters)
echo "Testing echo 0.5 2 | cct -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad" >> ${OUT}
echo 0.5 2 | cct -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad >> ${OUT}
echo "" >> ${OUT}
echo "Testing echo 0.5 2 | cct -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=deg" >> ${OUT}
echo 0.5 2 | cct -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=deg >> ${OUT}
echo "" >> ${OUT}
echo "Testing echo 0.5 2 | cct -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=m +xy_out=km" >> ${OUT}
echo 0.5 2 | cct -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=m +xy_out=km >> ${OUT}
echo "" >> ${OUT}
# tests for which the number of decimals is specified (-d 6)
echo "Testing echo 0.5 2 | cct -d 6 -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad" >> ${OUT}
echo 0.5 2 | cct -d 6 -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad >> ${OUT}
echo "" >> ${OUT}
echo "Testing echo 0.5 2 | cct -d 6 -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=deg" >> ${OUT}
echo 0.5 2 | cct -d 6 -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=deg >> ${OUT}
echo "" >> ${OUT}
echo "Testing echo 0.5 2 | cct -d 6 -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=m +xy_out=km" >> ${OUT}
echo 0.5 2 | cct -d 6 -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=m +xy_out=km >> ${OUT}
echo "" >> ${OUT}
# do 'diff' with distribution results
echo "diff ${OUT} with testcct_out.dist"
diff -u ${OUT} ${TEST_CLI_DIR}/testcct_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
Testing cct -d 8 +proj=merc +R=1
1.57079633 0.88137359 0.00000000 inf
Testing echo 0.5 2 | cct -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad
0.5000000000 2.0000000000 0.0000 0.0000
Testing echo 0.5 2 | cct -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=deg
0.5000000000 2.0000000000 0.0000 0.0000
Testing echo 0.5 2 | cct -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=m +xy_out=km
0.0005 0.0020 0.0000 0.0000
Testing echo 0.5 2 | cct -d 6 -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad
0.500000 2.000000 0.000000 0.0000
Testing echo 0.5 2 | cct -d 6 -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=deg
0.500000 2.000000 0.000000 0.0000
Testing echo 0.5 2 | cct -d 6 -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=m +xy_out=km
0.000500 0.002000 0.000000 0.0000
|
Modify testcct, and adjust testcct_out.dist accordingly (you can use the generated file test/cli/testcct_out to refresh testcct_out.dist). Make sure that "make check" passes, and then git commit the files and git push |
On 2020-11-27 23:14, Even Rouault wrote:
> I have modified the files and attached them to this message. (testcct
> and testcct_out.dist)
Modify testcct, and adjust testcct_out.dist accordingly (you can use
the generated file test/cli/testcct_out to refresh testcct_out.dist).
Make sure that "make check" passes, and then git commit the files and
git push
I am sorry, I cannot get this working.
The named files have been modified; a pull request has been carried out.
However the modification depends on my modification of the file cct.cpp,
of which the commit has not been merged yet.
#2453
Regards,
Henri
|
It seems you've been working on different branches, which won't work. The following should work:
The first line make sure that you are working on the branch behind this pull request. The second line grabs your commit in the |
On request more tests have been added verifying the output of the cct utility. cct has an option (-d) which overrides the default value for the number of decimals (precision) that are printed when cct outputs the value of a coordinate. By default the arguments to the printf format string will be: * radians, degrees: width 14, precision 10 * meters: width 13, precision 4 [1] [1] height will be shown with a width of 12. Note: the 4th "coordinate", time, will always be shown with a precision of 4 decimals (and width 12). When overridden (using the -d option) all coordinates, but not time, will be shown with the specified decimals.
On 2020-11-28 10:52, Kristian Evers wrote:
> I am sorry, I cannot get this working.
It seems you've been working on different branches, which won't work.
The following *should* work:
Yes, correct (different branches). I realized the dependency, but I had
no clue how to solve this "github-wise".
```
git checkout fix
git cherry-pick f4f1b2
git push
```
Thank you for hand-holding. Much appreciated!!!
The first line make sure that you are working on the branch behind
this pull request. The second line grabs your commit in the `fix2`
branch (which your other pull request is based of) and adds it to the
`fix` branch. Last line of course pushes the updated branch to GitHub.
The pull request will be updated once the updated branch is pushed -
you don't need to create yet another pull request.
Indeed, one of the many things I do not understand. Deleting a branch
on the remote (fork), will close the PR (pull request) automatically.
However the PR was not closed when I issued the commands above.
Next, another error in testcct was pointed out to me; corrected it,
and "replaced" the last commit on the remote branch (fix), using a
forced push.
Again a different commit at the tip of the remote branch, but again
the PR was not closed ...
I am reading like crazy (stack overflow) in an attempt to understand
all this magic.
Even R. has closed PR #2465; I think this means that I can delete my
remote branch fix2 <==== TWO.
Once more, thanks for the help!
Regards,
Henri
|
Commits squashed and merged. Thanks Cherry-picked in 7.2 branch |
…es in output by cct (#2453) Currently the output of the cct utility is different between radians and degrees (as expected by cct), because of a bug in cct: $ printf "1 2\n" | cct -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad 1.0000000000 2.0000000000 0.0000 0.0000 $ printf "1 2\n" | cct -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=deg 1.0000 2.0000 0.0000 0.0000 The arguments to the printf format string are as follows: * radians: width 14, precision 10 * degrees: width 13, precision 4 (this is by mistake. bug!) After the suggested fix has been applied, output will be the same for both radians and degrees: $ printf "1 2\n" | cct -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad 1.0000000000 2.0000000000 0.0000 0.0000 $ printf "1 2\n" | cct -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=deg 1.0000000000 2.0000000000 0.0000 0.0000 The cause of the bug is that cct does test if it "has radians to output", but "neglects" to test if it "has degrees to output", resulting in using different arguments to the printf format string in the latter case. The fix makes cct test if it "has either radians or degrees to output".
On 2020-11-28 13:45, Even Rouault wrote:
Merged #2453 into master.
Sorry Even, something must have gone wrong. Following the advice
from Kristian E.,
git checkout fix
git cherry-pick f4f1b2
git push
your last modification of testcct:
64,65c64,65
< echo "3541657.3778 948984.2343 5201383.5231 2020.5" >> a
< echo "3541658.0000 948985.0000 5201384.0000 2020.5" >> b
---
echo "3541657.3778 948984.2343 5201383.5231 2020.5" > a
echo "3541658.0000 948985.0000 5201384.0000 2020.5" > b
got lost somehow, I think ...
(branch fix was created several days ago)
Still have to figure out the how ...
Sorry,
Henri
|
I don't see it as lost, once merged into master. See https://github.com/OSGeo/PROJ/blob/master/test/cli/testcct#L63 |
…es in output by cct
Currently the output of the cct utility is different between radians
and degrees (as expected by cct), because of a bug in cct:
$ printf "1 2\n" | cct -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad
1.0000000000 2.0000000000 0.0000 0.0000
$ printf "1 2\n" | cct -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=deg
1.0000 2.0000 0.0000 0.0000
The arguments to the printf format string are as follows:
After the suggested fix has been applied, output will be the same for
both radians and degrees:
$ printf "1 2\n" | cct -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad
1.0000000000 2.0000000000 0.0000 0.0000
$ printf "1 2\n" | cct -z 0 -t 0 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=deg
1.0000000000 2.0000000000 0.0000 0.0000
The cause of the bug is that cct does test if it "has radians to output",
but "neglects" to test if it "has degrees to output", resulting in using
different arguments to the printf format string in the latter case.
The fix makes cct test if it "has either radians or degrees to output".
Verified against v7.2.0
docs/source/*.rst
for new API