TileSource::TileSource( const TileSourceOptions& options ) : _options( options ) { this->setThreadSafeRefUnref( true ); if ( *options.L2CacheSize() > 0 ) { _memCache = new MemCache( *options.L2CacheSize() ); } else { OE_INFO << LC << "L2 Cache disabled" << std::endl; } if (_options.blacklistFilename().isSet()) { _blacklistFilename = _options.blacklistFilename().value(); } if (!_blacklistFilename.empty() && osgDB::fileExists(_blacklistFilename)) { _blacklist = TileBlacklist::read(_blacklistFilename); if (_blacklist.valid()) { OE_INFO << "Read blacklist from file" << _blacklistFilename << std::endl; } } if (!_blacklist.valid()) { //Initialize the blacklist if we couldn't read it. _blacklist = new TileBlacklist(); } }
int main(int argc, char** argv) { osg::ArgumentParser arguments(&argc,argv); osgViewer::Viewer viewer(arguments); s_mapNode = 0L; osg::Node* earthFile = MapNodeHelper().load(arguments, &viewer); if (earthFile) s_mapNode = MapNode::get(earthFile); if ( !s_mapNode ) { OE_WARN << "Unable to load earth file." << std::endl; return -1; } TileSourceOptions tileSourceOptions; tileSourceOptions.L2CacheSize() = 0; s_deformations = new DeformationTileSource(tileSourceOptions); ElevationLayerOptions elevationOpt; //elevationOpt.offset() = true; elevationOpt.name() = "deformation"; // This is the only way to get the l2 cache size to pass down even though we're not actually creating a tilesource from the options. elevationOpt.driver() = tileSourceOptions; ElevationLayer* layer = new ElevationLayer(elevationOpt, s_deformations); s_mapNode->getMap()->addElevationLayer(layer); osg::Group* root = new osg::Group(); viewer.setSceneData( root ); // install the programmable manipulator. viewer.setCameraManipulator( new osgEarth::Util::EarthManipulator() ); // The MapNode will render the Map object in the scene graph. root->addChild( earthFile ); viewer.addEventHandler( new DeformationHandler(root) ); // add some stock OSG handlers: viewer.addEventHandler(new osgViewer::StatsHandler()); viewer.addEventHandler(new osgViewer::WindowSizeHandler()); viewer.addEventHandler(new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet())); return viewer.run(); }
AGSMapCacheSource( const TileSourceOptions& options ) : TileSource( options ) { const Config& conf = options.getConfig(); // this is the AGS virtual directory pointing to the map cache _url = conf.value( PROPERTY_URL ); // the name of the map service cache _map = conf.value( PROPERTY_MAP ); // the layer, or null to use the fused "_alllayers" cache _layer = conf.value( PROPERTY_LAYER ); // the image format (defaults to "png") // TODO: read this from the XML tile schema file _format = conf.value( PROPERTY_FORMAT ); // validate dataset if ( _layer.empty() ) _layer = "_alllayers"; // default to the AGS "fused view" if ( _format.empty() ) _format = "png"; }
TileSource::TileSource( const TileSourceOptions& options ) : _options( options ), _status ( Status::Error("Not initialized") ) { this->setThreadSafeRefUnref( true ); int l2CacheSize = 0; char const* l2env = ::getenv( "OSGEARTH_L2_CACHE_SIZE" ); if ( l2env ) { l2CacheSize = as<int>( std::string(l2env), 0 ); } else if ( *options.L2CacheSize() > 0 ) { _memCache = new MemCache( *options.L2CacheSize() ); } if (_options.blacklistFilename().isSet()) { _blacklistFilename = _options.blacklistFilename().value(); } if (!_blacklistFilename.empty() && osgDB::fileExists(_blacklistFilename)) { _blacklist = TileBlacklist::read(_blacklistFilename); if (_blacklist.valid()) { OE_INFO << "Read blacklist from file" << _blacklistFilename << std::endl; } } if (!_blacklist.valid()) { //Initialize the blacklist if we couldn't read it. _blacklist = new TileBlacklist(); } }
FeatureTileSource::FeatureTileSource( const TileSourceOptions& options ) : TileSource ( options ), _options ( options.getConfig() ), _initialized( false ) { if ( _options.featureSource().valid() ) { _features = _options.featureSource().get(); } else if ( _options.featureOptions().isSet() ) { _features = FeatureSourceFactory::create( _options.featureOptions().value() ); if ( !_features.valid() ) { OE_WARN << LC << "Failed to create FeatureSource from options" << std::endl; } } }