osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthDrivers/wms/WMSOptions

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_WMS_DRIVEROPTIONS
00020 #define OSGEARTH_DRIVER_WMS_DRIVEROPTIONS 1
00021 
00022 #include <osgEarth/Common>
00023 #include <osgEarth/TileSource>
00024 
00025 
00026 namespace osgEarth { namespace Drivers
00027 {
00028     using namespace osgEarth;
00029 
00030     class WMSOptions : public TileSourceOptions // NO EXPORT; header only
00031     {
00032     public:
00033         optional<URI>& url() { return _url; }
00034         const optional<URI>& url() const { return _url; }
00035 
00036         optional<URI>& capabilitiesUrl() { return _capabilitiesUrl; }
00037         const optional<URI>& capabilitiesUrl() const { return _capabilitiesUrl; }
00038 
00039         optional<URI>& tileServiceUrl() { return _tileServiceUrl; }
00040         const optional<URI>& tileServiceUrl() const { return _tileServiceUrl; }
00041 
00042         optional<std::string>& layers() { return _layers; }
00043         const optional<std::string>& layers() const { return _layers; }
00044 
00045         optional<std::string>& style() { return _style; }
00046         const optional<std::string>& style() const { return _style; }
00047 
00048         optional<std::string>& format() { return _format; }
00049         const optional<std::string>& format() const { return _format; }
00050 
00051         optional<std::string>& wmsFormat() { return _wmsFormat; }
00052         const optional<std::string>& wmsFormat() const { return _wmsFormat; }
00053 
00054         optional<std::string>& wmsVersion() { return _wmsVersion; }
00055         const optional<std::string>& wmsVersion() const { return _wmsVersion; }
00056 
00057         optional<std::string>& elevationUnit() { return _elevationUnit; }
00058         const optional<std::string>& elevationUnit() const { return _elevationUnit; }
00059 
00060         optional<std::string>& srs() { return _srs; }
00061         const optional<std::string>& srs() const { return _srs; }
00062 
00063         optional<bool>& transparent() { return _transparent; }
00064         const optional<bool>& transparent() const { return _transparent; }
00065 
00066         optional<std::string>& times() { return _times; }
00067         const optional<std::string>& times() const { return _times; }
00068 
00069         optional<double>& secondsPerFrame() { return _secondsPerFrame; }
00070         const optional<double>& secondsPerFrame() const { return _secondsPerFrame; }
00071 
00072     public:
00073         WMSOptions( const TileSourceOptions& opt =TileSourceOptions() ) : TileSourceOptions( opt ),
00074             _wmsVersion( "1.1.1" ),
00075             _elevationUnit( "m" ),
00076             _transparent( true ),
00077             _secondsPerFrame( 1.0 )
00078         {
00079             setDriver( "wms" );
00080             fromConfig( _conf );
00081         }
00082 
00083     public:
00084         Config getConfig() const {
00085             Config conf = TileSourceOptions::getConfig();
00086             conf.updateIfSet("url", _url);
00087             conf.updateIfSet("capabilities_url", _capabilitiesUrl);
00088             conf.updateIfSet("tile_service_url", _tileServiceUrl);
00089             conf.updateIfSet("layers", _layers);
00090             conf.updateIfSet("style", _style);
00091             conf.updateIfSet("format", _format);
00092             conf.updateIfSet("wms_format", _wmsFormat);
00093             conf.updateIfSet("wms_version", _wmsVersion);
00094             conf.updateIfSet("elevation_unit", _elevationUnit);
00095             conf.updateIfSet("srs", _srs);
00096             conf.updateIfSet("transparent", _transparent);
00097             conf.updateIfSet("times", _times);
00098             conf.updateIfSet("seconds_per_frame", _secondsPerFrame );
00099             return conf;
00100         }
00101 
00102     protected:
00103         void mergeConfig( const Config& conf ) {
00104             TileSourceOptions::mergeConfig( conf );
00105             fromConfig( conf );
00106         }
00107 
00108     private:
00109         void fromConfig( const Config& conf ) {
00110             conf.getIfSet("url", _url);
00111             conf.getIfSet("capabilities_url", _capabilitiesUrl);
00112             conf.getIfSet("tile_service_url", _tileServiceUrl);
00113             conf.getIfSet("layers", _layers);
00114             conf.getIfSet("style", _style);
00115             conf.getIfSet("format", _format);
00116             conf.getIfSet("wms_format", _wmsFormat);
00117             conf.getIfSet("wms_version", _wmsVersion);
00118             conf.getIfSet("elevation_unit", _elevationUnit);
00119             conf.getIfSet("srs", _srs);
00120             conf.getIfSet("transparent", _transparent);
00121             conf.getIfSet("times", _times);
00122             conf.getIfSet("seconds_per_frame", _secondsPerFrame );
00123         }
00124 
00125         optional<URI>         _url;
00126         optional<URI>         _capabilitiesUrl;
00127         optional<URI>         _tileServiceUrl;
00128         optional<std::string> _layers;
00129         optional<std::string> _style;
00130         optional<std::string> _format;
00131         optional<std::string> _wmsFormat;
00132         optional<std::string> _wmsVersion;
00133         optional<std::string> _elevationUnit;
00134         optional<std::string> _srs;
00135         optional<bool>        _transparent;
00136         optional<std::string> _times;
00137         optional<double>      _secondsPerFrame;
00138     };
00139 
00140 } } // namespace osgEarth::Drivers
00141 
00142 #endif // OSGEARTH_DRIVER_WMS_DRIVEROPTIONS
00143 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines