diff --git a/examples/osgdem/osgdem.cpp b/examples/osgdem/osgdem.cpp index 20d70c9cc..e77f64105 100644 --- a/examples/osgdem/osgdem.cpp +++ b/examples/osgdem/osgdem.cpp @@ -115,6 +115,7 @@ void processFile(std::string filename, osg::Matrixd &geoTransform, bool geoTransformSet, bool geoTransformScale, + bool minmaxLevelSet, unsigned int min_level, unsigned int max_level, osg::ref_ptr dataset) { if(filename.empty()) return; @@ -139,6 +140,10 @@ void processFile(std::string filename, osgTerrain::DataSet::Source::PREFER_CONFIG_SETTINGS); source->setGeoTransform(geoTransform); } + if (minmaxLevelSet) + { + source->setMinMaxLevel(min_level, max_level); + } dataset->addSource(source); } @@ -152,7 +157,10 @@ void processFile(std::string filename, for(i = dirContents.begin(); i != dirContents.end(); ++i) { if((*i != ".") && (*i != "..")) { fullfilename = filename + '/' + *i; - processFile(fullfilename, type, currentCS, geoTransform, geoTransformSet, geoTransformScale, dataset); + processFile(fullfilename, type, currentCS, + geoTransform, geoTransformSet, geoTransformScale, + minmaxLevelSet, min_level, max_level, + dataset); } } } @@ -327,7 +335,7 @@ int main( int argc, char **argv ) return 1; } - + unsigned int maximumPossibleLevel = 30; // read the input data @@ -338,6 +346,8 @@ int main( int argc, char **argv ) bool geoTransformSet = false; bool geoTransformScale = false; double xMin, xMax, yMin, yMax; + bool minmaxLevelSet = false; + unsigned int min_level=0, max_level=maximumPossibleLevel; int pos = 1; while(pos_source = this; } SourceData* getSourceData() { return _sourceData.get(); } @@ -279,6 +294,9 @@ class OSGTERRAIN_EXPORT DataSet : public osg::Referenced ParameterPolicy _coordinateSystemPolicy; ParameterPolicy _geoTransformPolicy; + + unsigned int _minLevel; + unsigned int _maxLevel; osg::ref_ptr _sourceData; diff --git a/src/osgTerrain/DataSet.cpp b/src/osgTerrain/DataSet.cpp index 5bae2f584..d7fd46437 100644 --- a/src/osgTerrain/DataSet.cpp +++ b/src/osgTerrain/DataSet.cpp @@ -2416,12 +2416,18 @@ void DataSet::DestinationTile::readFrom(CompositeSource* sourceGraph) for(CompositeSource::source_iterator itr(sourceGraph);itr.valid();++itr) { - SourceData* data = (*itr)->getSourceData(); - if (data) + Source* source = itr->get(); + + if (_level>=source->getMinLevel() && _level<=source->getMaxLevel()) { - std::cout<<"DataSet::DestinationTile::readFrom -> SourceData::read() "<read(*_imagery); - if (_terrain.valid()) data->read(*_terrain); + SourceData* data = (*itr)->getSourceData(); + if (data) + { + std::cout<<"DataSet::DestinationTile::readFrom -> SourceData::read() "<getMinLevel()<<"\t"<getMaxLevel()<read(*_imagery); + if (_terrain.valid()) data->read(*_terrain); + } } }