osgEarth 2.1.1
|
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_GDAL_DRIVEROPTIONS 00020 #define OSGEARTH_DRIVER_GDAL_DRIVEROPTIONS 1 00021 00022 #include <osgEarth/Common> 00023 #include <osgEarth/TileSource> 00024 #include <osgEarth/HeightFieldUtils> 00025 00026 namespace osgEarth { namespace Drivers 00027 { 00028 using namespace osgEarth; 00029 00030 class GDALOptions : public TileSourceOptions // NO EXPORT; header only 00031 { 00032 public: // properties 00033 00034 optional<URI>& url() { return _url; } 00035 const optional<URI>& url() const { return _url; } 00036 00037 optional<std::string>& extensions() { return _extensions; } 00038 const optional<std::string>& extensions() const { return _extensions; } 00039 00040 optional<ElevationInterpolation>& interpolation() { return _interpolation; } 00041 const optional<ElevationInterpolation>& interpolation() const { return _interpolation; } 00042 00043 optional<unsigned int>& maxDataLevel() { return _maxDataLevel;} 00044 const optional<unsigned int>& maxDataLevel() const { return _maxDataLevel;} 00045 00046 optional<bool>& interpolateImagery() { return _interpolateImagery;} 00047 const optional<bool>& interpolateImagery() const { return _interpolateImagery;} 00048 00049 public: // ctors 00050 00051 GDALOptions( const TileSourceOptions& options =TileSourceOptions() ) : 00052 TileSourceOptions( options ), 00053 _interpolation( INTERP_AVERAGE ), 00054 _interpolateImagery( false ) 00055 { 00056 setDriver( "gdal" ); 00057 fromConfig( _conf ); 00058 } 00059 00060 protected: 00061 00062 Config getConfig() const 00063 { 00064 Config conf = TileSourceOptions::getConfig(); 00065 conf.updateIfSet( "url", _url ); 00066 conf.updateIfSet( "extensions", _extensions ); 00067 00068 if ( _interpolation.isSet() ) { 00069 if ( _interpolation.value() == osgEarth::INTERP_NEAREST ) conf.update( "interpolation", "nearest" ); 00070 else if ( _interpolation.value() == osgEarth::INTERP_AVERAGE ) conf.update( "interpolation", "average" ); 00071 else if ( _interpolation.value() == osgEarth::INTERP_BILINEAR ) conf.update( "interpolation", "bilinear" ); 00072 } 00073 00074 conf.updateIfSet( "max_data_level", _maxDataLevel); 00075 00076 conf.updateIfSet( "interp_imagery", _interpolateImagery); 00077 return conf; 00078 } 00079 00080 void mergeConfig( const Config& conf ) { 00081 TileSourceOptions::mergeConfig( conf ); 00082 fromConfig( conf ); 00083 } 00084 00085 void fromConfig( const Config& conf ) { 00086 conf.getIfSet( "url", _url ); 00087 conf.getIfSet( "extensions", _extensions ); 00088 std::string in = conf.value( "interpolation" ); 00089 if ( in == "nearest" ) _interpolation = osgEarth::INTERP_NEAREST; 00090 else if ( in == "average" ) _interpolation = osgEarth::INTERP_AVERAGE; 00091 else if ( in == "bilinear" ) _interpolation = osgEarth::INTERP_BILINEAR; 00092 conf.getIfSet( "max_data_level", _maxDataLevel); 00093 00094 conf.getIfSet("interp_imagery", _interpolateImagery); 00095 } 00096 00097 optional<URI> _url; 00098 optional<std::string> _extensions; 00099 optional<ElevationInterpolation> _interpolation; 00100 optional<bool> _interpolateImagery; 00101 optional<unsigned> _maxDataLevel; 00102 }; 00103 00104 } } // namespace osgEarth::Drivers 00105 00106 #endif // OSGEARTH_DRIVER_GDAL_DRIVEROPTIONS 00107