Skip to content

Commit

Permalink
Ellipsoid::_isEquivalentTo(): fix so that an ellipsoid of semi-major …
Browse files Browse the repository at this point in the history
…axis A (and non-zero inv flattening) isn't equivalent to a sphere of radius A...

or to another ellipsoid of same semi-major axis but defined from a semi-minor axis and not inverse flattening

Discovered when debugging corner cases of #3879 ...
  • Loading branch information
rouault authored and github-actions[bot] committed Sep 5, 2023
1 parent 707dd9f commit 069e463
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/iso19111/datum.cpp
Expand Up @@ -1156,7 +1156,7 @@ bool Ellipsoid::_isEquivalentTo(const util::IComparable *other,
}

} else {
if (!otherEllipsoid->computeSemiMinorAxis()._isEquivalentTo(
if (!computeSemiMinorAxis()._isEquivalentTo(
otherEllipsoid->computeSemiMinorAxis(), criterion)) {
return false;
}
Expand Down
6 changes: 6 additions & 0 deletions test/unit/test_datum.cpp
Expand Up @@ -124,6 +124,12 @@ TEST(datum, ellipsoid_from_inverse_flattening) {

EXPECT_FALSE(Ellipsoid::WGS84->isEquivalentTo(
Ellipsoid::GRS1980.get(), IComparable::Criterion::EQUIVALENT));

auto sphere = Ellipsoid::createSphere(PropertyMap(), Length(6378137));
EXPECT_FALSE(Ellipsoid::WGS84->isEquivalentTo(
sphere.get(), IComparable::Criterion::EQUIVALENT));
EXPECT_FALSE(sphere->isEquivalentTo(Ellipsoid::WGS84.get(),
IComparable::Criterion::EQUIVALENT));
}

// ---------------------------------------------------------------------------
Expand Down

0 comments on commit 069e463

Please sign in to comment.