Skip to content

Commit

Permalink
Fix earth pole region error
Browse files Browse the repository at this point in the history
  • Loading branch information
Yankes authored and MeridianOXC committed Jul 23, 2023
1 parent 82b7b11 commit 138aaab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/Mod/RuleCountry.cpp
Expand Up @@ -131,7 +131,10 @@ bool RuleCountry::insideCountry(double lon, double lat) const
else
inLon = ((lon >= _lonMin[i] && lon < M_PI*2.0) || (lon >= 0 && lon < _lonMax[i]));

inLat = (lat >= _latMin[i] && lat < _latMax[i]);
if (lat > 0) // make that both poles could be in some regions, this means `M_PI == _latMax[i]` or `-M_PI == _latMin[i]`
inLat = (lat > _latMin[i] && lat <= _latMax[i]);
else
inLat = (lat >= _latMin[i] && lat < _latMax[i]);

if (inLon && inLat)
return true;
Expand Down
5 changes: 4 additions & 1 deletion src/Mod/RuleRegion.cpp
Expand Up @@ -109,7 +109,10 @@ bool RuleRegion::insideRegion(double lon, double lat) const
else
inLon = ((lon >= _lonMin[i] && lon < M_PI*2.0) || (lon >= 0 && lon < _lonMax[i]));

inLat = (lat >= _latMin[i] && lat < _latMax[i]);
if (lat > 0) // make that both poles could be in some regions, this means `M_PI == _latMax[i]` or `-M_PI == _latMin[i]`
inLat = (lat > _latMin[i] && lat <= _latMax[i]);
else
inLat = (lat >= _latMin[i] && lat < _latMax[i]);

if (inLon && inLat)
return true;
Expand Down

0 comments on commit 138aaab

Please sign in to comment.