diff options
| author | Kristian Evers <kristianevers@gmail.com> | 2022-03-14 20:38:12 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-14 20:38:12 +0100 |
| commit | 77751f6c9e023748a90793774e8e4b554515e8b5 (patch) | |
| tree | 2175e085e4cf3a00c437f6678b3f4bdb2e851e9a /test/unit/gie_self_tests.cpp | |
| parent | 8d79aec108bdff20264cb5449ebfe8509f652dca (diff) | |
| parent | f04faeae6c9d3864362816db9b95968e54f95dc4 (diff) | |
| download | PROJ-77751f6c9e023748a90793774e8e4b554515e8b5.tar.gz PROJ-77751f6c9e023748a90793774e8e4b554515e8b5.zip | |
Merge pull request #3111 from direvus/1483-round-to-date
unitconvert: round to nearest date when converting to yyyymmdd.
Diffstat (limited to 'test/unit/gie_self_tests.cpp')
| -rw-r--r-- | test/unit/gie_self_tests.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/test/unit/gie_self_tests.cpp b/test/unit/gie_self_tests.cpp index 71df8fe1..5c14d747 100644 --- a/test/unit/gie_self_tests.cpp +++ b/test/unit/gie_self_tests.cpp @@ -618,7 +618,6 @@ static void test_time(const char *args, double tol, double t_in, double t_exp) { // --------------------------------------------------------------------------- TEST(gie, unitconvert_selftest) { - char args1[] = "+proj=unitconvert +t_in=decimalyear +t_out=decimalyear"; double in1 = 2004.25; @@ -641,6 +640,36 @@ TEST(gie, unitconvert_selftest) { test_time(args5, 1e-6, in5, in5); } +static void test_date(const char *args, double tol, double t_in, double t_exp) { + PJ_COORD in, out; + PJ *P = proj_create(PJ_DEFAULT_CTX, args); + + ASSERT_TRUE(P != 0); + + in = proj_coord(0.0, 0.0, 0.0, t_in); + + out = proj_trans(P, PJ_FWD, in); + EXPECT_NEAR(out.xyzt.t, t_exp, tol); + + proj_destroy(P); + + proj_log_level(NULL, PJ_LOG_NONE); +} + +TEST(gie, unitconvert_selftest_date) { + char args[] = "+proj=unitconvert +t_in=decimalyear +t_out=yyyymmdd"; + test_date(args, 1e-6, 2022.0027, 20220102); + test_date(args, 1e-6, 1990.0, 19900101); + test_date(args, 1e-6, 2004.1612, 20040229); + test_date(args, 1e-6, 1899.999, 19000101); + + strcpy(&args[18], "+t_in=yyyymmdd +t_out=decimalyear"); + test_date(args, 1e-6, 20220102, 2022.0027397); + test_date(args, 1e-6, 19900101, 1990.0); + test_date(args, 1e-6, 20040229, 2004.1612022); + test_date(args, 1e-6, 18991231, 1899.9972603); +} + static const char tc32_utm32[] = { " +proj=horner" " +ellps=intl" |
