Skip to content

Commit 4408185

Browse files
committedJul 5, 2011
Replaced earth file with programmatic map construction
1 parent 4c36e58 commit 4408185

File tree

3 files changed

+32
-71
lines changed

3 files changed

+32
-71
lines changed
 

‎src/plugins/globe/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,5 @@ INSTALL(TARGETS globeplugin
6969
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
7070
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})
7171

72-
INSTALL (FILES images/world.tif globe.earth
73-
DESTINATION ${QGIS_DATA_DIR}/globe)
74-
7572
INSTALL (DIRECTORY data images/gui
7673
DESTINATION ${QGIS_DATA_DIR}/globe)

‎src/plugins/globe/globe.earth

Lines changed: 0 additions & 45 deletions
This file was deleted.

‎src/plugins/globe/globe_plugin.cpp

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include <osgEarth/Map>
5151
#include <osgEarth/MapNode>
5252
#include <osgEarth/TileSource>
53+
#include <osgEarthUtil/AutoClipPlaneHandler>
5354
#include <osgEarthDrivers/gdal/GDALOptions>
5455
#include "WorldWindOptions"
5556
#include <osgEarthDrivers/tms/TMSOptions>
@@ -227,6 +228,8 @@ void GlobePlugin::run()
227228
// install the programmable manipulator.
228229
osgEarth::Util::EarthManipulator* manip = new osgEarth::Util::EarthManipulator();
229230
viewer.setCameraManipulator( manip );
231+
// add a handler that will automatically calculate good clipping planes
232+
//viewer.addEventHandler( new osgEarth::Util::AutoClipPlaneHandler() );
230233

231234
setupMap();
232235

@@ -272,38 +275,41 @@ void GlobePlugin::settings()
272275

273276
void GlobePlugin::setupMap()
274277
{
275-
// read base layers from earth file
276-
QString earthFileName = QDir::cleanPath( QgsApplication::pkgDataPath() + "/globe/globe.earth" );
277-
QFile earthFileTemplate( earthFileName );
278-
if( !earthFileTemplate.open( QIODevice::ReadOnly | QIODevice::Text ) )
279-
{
280-
return;
281-
}
282-
283-
QTextStream in( &earthFileTemplate );
284-
QString earthxml = in.readAll();
285278
QSettings settings;
286279
QString cacheDirectory = settings.value( "cache/directory", QgsApplication::qgisSettingsDirPath() + "cache" ).toString();
287-
earthxml.replace( "/home/pi/devel/gis/qgis/.qgis/cache", cacheDirectory );
288-
earthxml.replace( "/usr/share/osgearth/data", QDir::cleanPath( QgsApplication::pkgDataPath() + "/globe" ) );
280+
TMSCacheOptions cacheOptions;
281+
cacheOptions.setPath(cacheDirectory.toStdString());
282+
283+
MapOptions mapOptions;
284+
mapOptions.cache() = cacheOptions;
285+
osgEarth::Map *map = new osgEarth::Map(mapOptions);
286+
287+
//Default image layer
288+
GDALOptions driverOptions;
289+
driverOptions.url() = QDir::cleanPath( QgsApplication::pkgDataPath() + "/globe/world.tif" ).toStdString();
290+
ImageLayerOptions layerOptions( "world", driverOptions );
291+
layerOptions.cacheEnabled() = false;
292+
map->addImageLayer( new osgEarth::ImageLayer( layerOptions ) );
293+
294+
MapNodeOptions nodeOptions;
295+
//nodeOptions.proxySettings() =
296+
//nodeOptions.enableLighting() = false;
297+
298+
//LoadingPolicy loadingPolicy( LoadingPolicy::MODE_SEQUENTIAL );
299+
TerrainOptions terrainOptions;
300+
//terrainOptions.loadingPolicy() = loadingPolicy;
301+
nodeOptions.setTerrainOptions( terrainOptions );
302+
303+
// The MapNode will render the Map object in the scene graph.
304+
mMapNode = new osgEarth::MapNode( map, nodeOptions );
289305

290306
//prefill cache
291307
if( !QFile::exists( cacheDirectory + "/worldwind_srtm" ) )
292308
{
293309
copyFolder( QgsApplication::pkgDataPath() + "/globe/data/worldwind_srtm", cacheDirectory + "/globe/worldwind_srtm" );
294310
}
295311

296-
std::istringstream istream( earthxml.toStdString() );
297-
osg::Node* node = osgDB::readNodeFile( earthFileName.toStdString() ); //TODO: from istream earthFile.readXML( istream, earthFileName.toStdString() )
298-
if( !node )
299-
{
300-
return;
301-
}
302-
303312
mRootNode = new osg::Group();
304-
305-
// The MapNode will render the Map object in the scene graph.
306-
mMapNode = MapNode::findMapNode( node );
307313
mRootNode->addChild( mMapNode );
308314

309315
// Add layers to the map
@@ -677,8 +683,11 @@ void GlobePlugin::layersChanged()
677683
else if ( "Worldwind" == type )
678684
{
679685
WorldWindOptions options;
680-
//TODO: <heightfield name=\"WorldWind bil\" driver=\"worldwind\"><worldwind_cache>" + cacheDirectory.toStdString() + "/globe/worldwind_srtm";
686+
options.elevationCachePath() = cacheDirectory.toStdString() + "/globe/worldwind_srtm";
681687
layer = new osgEarth::ElevationLayer( "WorldWind bil", options );
688+
TerrainEngineNode* terrainEngineNode = mMapNode->getTerrainEngine();
689+
terrainEngineNode->setVerticalScale(2);
690+
terrainEngineNode->setElevationSamplingRatio(0.25);
682691
}
683692
else if ( "TMS" == type )
684693
{

0 commit comments

Comments
 (0)
Please sign in to comment.