Skip to content

Commit

Permalink
Merge pull request #3408 from rouault/fix_3407
Browse files Browse the repository at this point in the history
VerticalCRS::_isEquivalentTo(): do not consider VerticalCRS and DerivedVerticalCRS as equivalent
  • Loading branch information
rouault authored and github-actions[bot] committed Oct 21, 2022
1 parent 0544964 commit ea292b0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/iso19111/crs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3706,6 +3706,10 @@ bool VerticalCRS::_isEquivalentTo(
const util::IComparable *other, util::IComparable::Criterion criterion,
const io::DatabaseContextPtr &dbContext) const {
auto otherVertCRS = dynamic_cast<const VerticalCRS *>(other);
if (otherVertCRS == nullptr ||
!util::isOfExactType<VerticalCRS>(*otherVertCRS)) {
return false;
}
// TODO test geoidModel and velocityModel
return otherVertCRS != nullptr &&
SingleCRS::baseIsEquivalentTo(other, criterion, dbContext);
Expand Down
17 changes: 13 additions & 4 deletions test/unit/test_crs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5962,6 +5962,19 @@ TEST(crs, parametricCRS_WKT1) {

// ---------------------------------------------------------------------------

TEST(crs, derivedVerticalCRS_basic) {

auto crs = createDerivedVerticalCRS();
EXPECT_TRUE(crs->isEquivalentTo(crs.get()));
EXPECT_TRUE(crs->shallowClone()->isEquivalentTo(crs.get()));
EXPECT_TRUE(!crs->isEquivalentTo(createUnrelatedObject().get()));

EXPECT_FALSE(crs->isEquivalentTo(crs->baseCRS().get()));
EXPECT_FALSE(crs->baseCRS()->isEquivalentTo(crs.get()));
}

// ---------------------------------------------------------------------------

TEST(crs, DerivedVerticalCRS_WKT2) {

auto expected = "VERTCRS[\"Derived vertCRS\",\n"
Expand All @@ -5976,10 +5989,6 @@ TEST(crs, DerivedVerticalCRS_WKT2) {
" ID[\"EPSG\",9001]]]]";

auto crs = createDerivedVerticalCRS();
EXPECT_TRUE(crs->isEquivalentTo(crs.get()));
EXPECT_TRUE(crs->shallowClone()->isEquivalentTo(crs.get()));
EXPECT_TRUE(!crs->isEquivalentTo(createUnrelatedObject().get()));

EXPECT_EQ(crs->exportToWKT(
WKTFormatter::create(WKTFormatter::Convention::WKT2).get()),
expected);
Expand Down

0 comments on commit ea292b0

Please sign in to comment.