From c99cfa8ee743251faba9bc04ee5cf5a6010359eb Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 1 Jul 2020 14:14:24 +0200 Subject: WKT parser: do not raise warning when parsing a WKT2:2015 TIMECRS whose TIMEUNIT is at the CS level, and not inside (#2276) Adresses testTemporal() and testCompoundWithTime() cases of https://github.com/OSGeo/PROJ/issues/2275#issuecomment-650765730 --- test/unit/test_io.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp index ddef0833..6c92b57d 100644 --- a/test/unit/test_io.cpp +++ b/test/unit/test_io.cpp @@ -4013,7 +4013,7 @@ TEST(wkt_parse, TemporalDatum_no_calendar) { // --------------------------------------------------------------------------- -TEST(wkt_parse, dateTimeTemporalCRS_WKT2) { +TEST(wkt_parse, dateTimeTemporalCRS_WKT2_2015) { auto wkt = "TIMECRS[\"Temporal CRS\",\n" " TDATUM[\"Gregorian calendar\",\n" " TIMEORIGIN[0000-01-01]],\n" @@ -4121,6 +4121,34 @@ TEST(wkt_parse, temporalCountCRSWithoutConvFactor_WKT2_2019) { // --------------------------------------------------------------------------- +TEST(wkt_parse, temporalMeasureCRS_WKT2_2015) { + auto wkt = "TIMECRS[\"GPS Time\",\n" + " TDATUM[\"Time origin\",\n" + " TIMEORIGIN[1980-01-01T00:00:00.0Z]],\n" + " CS[temporal,1],\n" + " AXIS[\"time\",future],\n" + " TIMEUNIT[\"day\",86400.0]]"; + + auto obj = WKTParser().createFromWKT(wkt); + auto crs = nn_dynamic_pointer_cast(obj); + ASSERT_TRUE(crs != nullptr); + + EXPECT_EQ(crs->nameStr(), "GPS Time"); + auto tdatum = crs->datum(); + EXPECT_EQ(tdatum->nameStr(), "Time origin"); + EXPECT_EQ(tdatum->temporalOrigin().toString(), "1980-01-01T00:00:00.0Z"); + EXPECT_TRUE(nn_dynamic_pointer_cast( + crs->coordinateSystem()) != nullptr); + auto cs = crs->coordinateSystem(); + ASSERT_EQ(cs->axisList().size(), 1U); + auto axis = cs->axisList()[0]; + EXPECT_EQ(axis->nameStr(), "Time"); + EXPECT_EQ(axis->unit().name(), "day"); + EXPECT_EQ(axis->unit().conversionToSI(), 86400.0); +} + +// --------------------------------------------------------------------------- + TEST(wkt_parse, temporalMeasureCRSWithoutConvFactor_WKT2_2019) { auto wkt = "TIMECRS[\"Decimal Years CE\",\n" " TIMEDATUM[\"Common Era\",\n" -- cgit v1.2.3