Skip to content

Commit

Permalink
Simplify the normalizeX code in GeoExtent
Browse files Browse the repository at this point in the history
  • Loading branch information
gwaldron committed Jul 24, 2024
1 parent c5dfee9 commit 5f3d31b
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions src/osgEarth/GeoData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ GeoExtent::operator != ( const GeoExtent& rhs ) const
bool
GeoExtent::crossesAntimeridian() const
{
return _srs.valid() && _srs->isGeographic() && east() < west(); //west()+width() > 180.0;
return _srs.valid() && _srs->isGeographic() && east() < west();
}

bool
Expand Down Expand Up @@ -1583,22 +1583,12 @@ GeoExtent::normalizeX(double x) const
{
if (is_valid(x) && _srs.valid() && _srs->isGeographic())
{
if (fabs(x) <= 180.0)
{
return x;
}

if (x < 0.0 || x >= 360.0)
{
x = fmod(x, 360.0);
if (x < 0.0)
x += 360.0;
}

if (x > 180.0)
{
// put x in the range [-180..180] inclusive on both ends.
x = fmod(x, 360.0);
if (x < -180.0)
x += 360.0;
else if (x > 180.0)
x -= 360.0;
}
}
return x;
}
Expand Down

0 comments on commit 5f3d31b

Please sign in to comment.