Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gwaldron/osgearth
Browse files Browse the repository at this point in the history
  • Loading branch information
gwaldron committed Jun 6, 2024
2 parents eaf65a9 + 17994d0 commit 09ddf84
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/osgEarth/ElevationRanges
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ namespace osgEarth

// Gets the min/max elevation at the given tile key index.
static bool getElevationRange(unsigned int level, unsigned int x, unsigned int y, short& min, short& max);

// Get the default min/max elevation range if no index data is available.
static bool getDefaultElevationRange(short& min, short& max);
};

} // namespace osgEarth
Expand Down
7 changes: 7 additions & 0 deletions src/osgEarth/ElevationRanges.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ osg::ref_ptr<const Profile> ElevationRanges::getProfile()
return Profile::create(Profile::GLOBAL_GEODETIC);
}

bool ElevationRanges::getDefaultElevationRange(short& min, short& max)
{
min = -2000;
max = 9000;
return true;
}

bool ElevationRanges::getElevationRange(unsigned int level, unsigned int x, unsigned int y, short& min, short& max)
{
osg::ref_ptr< const Profile > profile = getProfile();
Expand Down
11 changes: 9 additions & 2 deletions src/osgEarth/FeatureModelGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -806,13 +806,20 @@ FeatureModelGraph::getBoundInWorldCoords(const GeoExtent& extent, const Profile*
// Get the approximate elevation range if we have elevation data in the map
lod = osg::clampBetween(lod, 0u, ElevationRanges::getMaxLevel());
GeoPoint centerWGS84 = center.transform(ElevationRanges::getProfile()->getSRS());

TileKey rangeKey = ElevationRanges::getProfile()->createTileKey(centerWGS84.x(), centerWGS84.y(), lod);
short min, max;
ElevationRanges::getElevationRange(rangeKey.getLevelOfDetail(), rangeKey.getTileX(), rangeKey.getTileY(), min, max);
if (!*map->options().disableElevationRanges())
{
ElevationRanges::getElevationRange(rangeKey.getLevelOfDetail(), rangeKey.getTileX(), rangeKey.getTileY(), min, max);
}
else
{
ElevationRanges::getDefaultElevationRange(min, max);
}
// Clamp the min value to avoid extreme underwater values.
minElevation = osg::maximum(min, (short)-500);
// Add a little bit extra of extra height to account for feature data.
// Add a little bit extra of extra height to account for feature data.
maxElevation = max + 100.0f;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/osgEarth/Map
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,10 @@ namespace osgEarth
OE_OPTION(ProfileOptions, profile);
OE_OPTION(CacheOptions, cache);
OE_OPTION(CachePolicy, cachePolicy);
OE_OPTION(RasterInterpolation, elevationInterpolation);
OE_OPTION(RasterInterpolation, elevationInterpolation, INTERP_BILINEAR);
OE_OPTION(std::string, profileLayer);
OE_OPTION(std::string, osgOptionString);
OE_OPTION(bool, disableElevationRanges, false);
virtual Config getConfig() const;
private:
void fromConfig(const Config&);
Expand Down
8 changes: 5 additions & 3 deletions src/osgEarth/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ Map::Options::getConfig() const

conf.set("read_options", osgOptionString());

conf.set("disable_elevation_ranges", disableElevationRanges());

return conf;
}

void
Map::Options::fromConfig(const Config& conf)
{
elevationInterpolation().init(INTERP_BILINEAR);

{
conf.get( "name", name() );
conf.get( "profile", profile() );
conf.get( "cache", cache() );
Expand All @@ -93,6 +93,8 @@ Map::Options::fromConfig(const Config& conf)

conf.get("read_options", osgOptionString());
conf.get("osg_options", osgOptionString()); // back compat

conf.get("disable_elevation_ranges", disableElevationRanges());
}

//...................................................................
Expand Down
9 changes: 8 additions & 1 deletion src/osgEarth/SimplePager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,14 @@ osg::BoundingSphered SimplePager::getBounds(const TileKey& key) const
GeoPoint centerWGS84 = center.transform(ElevationRanges::getProfile()->getSRS());
TileKey rangeKey = ElevationRanges::getProfile()->createTileKey(centerWGS84.x(), centerWGS84.y(), lod);
short min, max;
ElevationRanges::getElevationRange(rangeKey.getLevelOfDetail(), rangeKey.getTileX(), rangeKey.getTileY(), min, max);
if (!*map->options().disableElevationRanges())
{
ElevationRanges::getElevationRange(rangeKey.getLevelOfDetail(), rangeKey.getTileX(), rangeKey.getTileY(), min, max);
}
else
{
ElevationRanges::getDefaultElevationRange(min, max);
}
// Clamp the min value to avoid extreme underwater values.
minElevation = osg::maximum(min, (short)-500);
// Add a little bit extra of extra height to account for feature data.
Expand Down

0 comments on commit 09ddf84

Please sign in to comment.