diff --git a/src/osgEarth/ElevationRanges b/src/osgEarth/ElevationRanges index b6fe47a306..78b81dc6ef 100644 --- a/src/osgEarth/ElevationRanges +++ b/src/osgEarth/ElevationRanges @@ -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 diff --git a/src/osgEarth/ElevationRanges.cpp b/src/osgEarth/ElevationRanges.cpp index 7c71e4789e..7d629654ef 100644 --- a/src/osgEarth/ElevationRanges.cpp +++ b/src/osgEarth/ElevationRanges.cpp @@ -34,6 +34,13 @@ osg::ref_ptr 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(); diff --git a/src/osgEarth/FeatureModelGraph.cpp b/src/osgEarth/FeatureModelGraph.cpp index 8a0fd6d12f..a37e4a8fed 100644 --- a/src/osgEarth/FeatureModelGraph.cpp +++ b/src/osgEarth/FeatureModelGraph.cpp @@ -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; } } diff --git a/src/osgEarth/Map b/src/osgEarth/Map index 042867d8d2..16204e44d2 100644 --- a/src/osgEarth/Map +++ b/src/osgEarth/Map @@ -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&); diff --git a/src/osgEarth/Map.cpp b/src/osgEarth/Map.cpp index 67a7af257a..6ea183a8b3 100644 --- a/src/osgEarth/Map.cpp +++ b/src/osgEarth/Map.cpp @@ -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() ); @@ -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()); } //................................................................... diff --git a/src/osgEarth/SimplePager.cpp b/src/osgEarth/SimplePager.cpp index 6143aacdf4..70bd49bad5 100644 --- a/src/osgEarth/SimplePager.cpp +++ b/src/osgEarth/SimplePager.cpp @@ -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.