osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthDrivers/vpb/VPBOptions

Go to the documentation of this file.
00001 /* -*-c++-*- */
00002 /* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
00003  * Copyright 2008-2010 Pelican Mapping
00004  * http://osgearth.org
00005  *
00006  * osgEarth is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU Lesser General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public License
00017  * along with this program.  If not, see <http://www.gnu.org/licenses/>
00018  */
00019 #ifndef OSGEARTH_DRIVER_VPB_DRIVEROPTIONS
00020 #define OSGEARTH_DRIVER_VPB_DRIVEROPTIONS 1
00021 
00022 #include <osgEarth/Common>
00023 #include <osgEarth/TileSource>
00024 
00025 namespace osgEarth { namespace Drivers
00026 {
00027     using namespace osgEarth;
00028 
00029     class VPBOptions : public TileSourceOptions // NO EXPORT; header only
00030     {
00031     public: // types
00032 
00033         enum DirectoryStructure {
00034             DS_NESTED,
00035             DS_TASK,
00036             DS_FLAT
00037         };
00038 
00039     public: // properties
00040 
00041         optional<URI>& url() { return _url; }
00042         const optional<URI>& url() const { return _url; }
00043 
00044         optional<int>& primarySplitLevel() { return _primarySplitLevel; }
00045         const optional<int>& primarySplitLevel() const { return _primarySplitLevel; }
00046 
00047         optional<int>& secondarySplitLevel() { return _secondarySplitLevel; }
00048         const optional<int>& secondarySplitLevel() const { return _secondarySplitLevel; }
00049 
00050         optional<DirectoryStructure>& directoryStructure() { return _dirStruct; }
00051         const optional<DirectoryStructure>& directoryStructure() const { return _dirStruct; }
00052 
00053         optional<int>& layer() { return _layer; }
00054         const optional<int>& layer() const { return _layer; }
00055 
00056                 optional<std::string>& layerSetName() { return _layerSetName; }
00057                 const optional<std::string>& layerSetName() const { return _layerSetName; }
00058 
00059         optional<int>& numTilesWideAtLod0() { return _widthLod0; }
00060         const optional<int>& numTilesWideAtLod0() const { return _widthLod0; }
00061 
00062         optional<int>& numTilesHighAtLod0() { return _heightLod0; }
00063         const optional<int>& numTilesHighAtLod0() const { return _heightLod0; }
00064 
00065         optional<std::string>& baseName() { return _baseName; }
00066         const optional<std::string>& baseName() const { return _baseName; }
00067 
00068     public:
00069         VPBOptions( const TileSourceOptions& opt =TileSourceOptions() ) : TileSourceOptions( opt ),
00070             _primarySplitLevel( INT_MAX ),
00071             _secondarySplitLevel( INT_MAX ),
00072             _layer( 0 ),
00073             _widthLod0( 1 ),
00074             _heightLod0( 1 ),
00075             _dirStruct( DS_NESTED )
00076         {
00077             setDriver( "vpb" );
00078             fromConfig( _conf );
00079         }
00080 
00081     public:
00082         Config getConfig() const {
00083             Config conf = TileSourceOptions::getConfig();
00084             conf.updateIfSet("url", _url);
00085             conf.updateIfSet("primary_split_level", _primarySplitLevel);
00086             conf.updateIfSet("secondary_split_level", _secondarySplitLevel);
00087             conf.updateIfSet("layer", _layer);
00088                         conf.updateIfSet("layer_setname", _layerSetName);
00089             conf.updateIfSet("num_tiles_wide_at_lod_0", _widthLod0 );
00090             conf.updateIfSet("num_tiles_high_at_lod_0", _heightLod0 );
00091             conf.updateIfSet("base_name", _baseName );
00092             if ( _dirStruct.isSet() ) {
00093                 if ( _dirStruct == DS_FLAT ) conf.update("directory_structure", "flat");
00094                 else if ( _dirStruct == DS_TASK ) conf.update("directory_structure", "task");
00095                 else if ( _dirStruct == DS_NESTED ) conf.update("directory_structure", "nested");
00096             }
00097             return conf;
00098         }
00099 
00100     protected:
00101         void mergeConfig( const Config& conf ) {
00102             TileSourceOptions::mergeConfig( conf );
00103             fromConfig( conf );
00104         }
00105 
00106     private:
00107         void fromConfig( const Config& conf ) {
00108             conf.getIfSet("url", _url);
00109             conf.getIfSet("primary_split_level", _primarySplitLevel);
00110             conf.getIfSet("secondary_split_level", _secondarySplitLevel);
00111             conf.getIfSet("layer", _layer);
00112                         conf.getIfSet("layer_setname", _layerSetName);
00113             conf.getIfSet("numTilesWideAtLod0", _widthLod0 );
00114             conf.getIfSet("numTilesHighAtLod0", _heightLod0 );
00115             conf.getIfSet("base_name", _baseName);
00116             
00117             std::string ds = conf.value("directory_structure");
00118             if ( ds == "flat" ) _dirStruct = DS_FLAT;
00119             else if ( ds == "task" ) _dirStruct = DS_TASK;
00120             else if ( ds == "nested" ) _dirStruct = DS_NESTED;
00121         }
00122 
00123         optional<URI>         _url;
00124         optional<std::string> _baseName, _layerSetName;
00125         optional<int>         _primarySplitLevel, _secondarySplitLevel, _layer, _widthLod0, _heightLod0;
00126         optional<DirectoryStructure> _dirStruct;
00127     };
00128 
00129 } } // namespace osgEarth::Drivers
00130 
00131 #endif // OSGEARTH_DRIVER_VPB_DRIVEROPTIONS
00132 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines