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_FEATURES_GEOMETRY_COMPILER_H 00020 #define OSGEARTH_FEATURES_GEOMETRY_COMPILER_H 1 00021 00022 #include <osgEarthFeatures/Common> 00023 #include <osgEarthFeatures/Feature> 00024 #include <osgEarthFeatures/FeatureCursor> 00025 #include <osgEarthFeatures/ResampleFilter> 00026 #include <osgEarthSymbology/Style> 00027 #include <osgEarth/GeoMath> 00028 00029 namespace osgEarth { namespace Features 00030 { 00031 using namespace osgEarth; 00032 using namespace osgEarth::Symbology; 00033 00034 class OSGEARTHFEATURES_EXPORT GeometryCompilerOptions : public ConfigOptions 00035 { 00036 public: 00037 GeometryCompilerOptions( const ConfigOptions& conf =ConfigOptions() ); 00038 00039 public: 00041 optional<double>& maxGranularity() { return _maxGranularity_deg; } 00042 const optional<double>& maxGranularity() const { return _maxGranularity_deg; } 00043 00045 optional<GeoInterpolation>& geoInterp() { return _geoInterp; } 00046 const optional<GeoInterpolation>& geoInterp() const { return _geoInterp; } 00047 00049 optional<bool>& mergeGeometry() { return _mergeGeometry; } 00050 const optional<bool>& mergeGeometry() const { return _mergeGeometry; } 00051 00053 optional<StringExpression>& featureName() { return _featureNameExpr; } 00054 const optional<StringExpression>& featureName() const { return _featureNameExpr; } 00055 00057 optional<bool>& clustering() { return _clustering; } 00058 const optional<bool>& clustering() const { return _clustering; } 00059 00060 //todo: merge this with geoInterp() 00061 optional<osgEarth::Features::ResampleFilter::ResampleMode>& resampleMode() { return _resampleMode;} 00062 const optional<osgEarth::Features::ResampleFilter::ResampleMode>& resampleMode() const { return _resampleMode;} 00063 00064 optional<double>& resampleMaxLength() { return _resampleMaxLength; } 00065 const optional<double>& resampleMaxLength() const { return _resampleMaxLength;} 00066 00067 00068 00069 public: 00070 Config getConfig() const; 00071 void mergeConfig( const Config& conf ); 00072 00073 private: 00074 optional<double> _maxGranularity_deg; 00075 optional<GeoInterpolation> _geoInterp; 00076 optional<bool> _mergeGeometry; 00077 optional<StringExpression> _featureNameExpr; 00078 optional<bool> _clustering; 00079 optional<osgEarth::Features::ResampleFilter::ResampleMode> _resampleMode; 00080 optional<double> _resampleMaxLength; 00081 00082 void fromConfig( const Config& conf ); 00083 }; 00084 00088 class OSGEARTHFEATURES_EXPORT GeometryCompiler 00089 { 00090 public: 00091 00093 GeometryCompiler(); 00094 00096 GeometryCompiler( const GeometryCompilerOptions& options ); 00097 00099 const GeometryCompilerOptions& options() const { return _options; } 00100 00102 GeometryCompilerOptions& options() { return _options; } 00103 00104 public: 00105 00107 osg::Node* compile( 00108 FeatureCursor* input, 00109 const Style& style, 00110 const FilterContext& context); 00111 00112 osg::Node* compile( 00113 Feature* input, 00114 const Style& style, 00115 const FilterContext& context); 00116 00117 osg::Node* compile( 00118 FeatureList& mungeableInput, 00119 const Style& style, 00120 const FilterContext& context); 00121 00122 protected: 00123 GeometryCompilerOptions _options; 00124 }; 00125 00126 } } // namespace osgEarth::Features 00127 00128 #endif // OSGEARTH_FEATURES_GEOMETRY_COMPILER_H