osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthFeatures/FeatureGridder

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 
00020 #ifndef OSGEARTHFEATURES_FEATURE_GRIDDER_H
00021 #define OSGEARTHFEATURES_FEATURE_GRIDDER_H 1
00022 
00023 #include <osgEarthFeatures/Common>
00024 #include <osgEarthFeatures/Feature>
00025 #include <osgEarth/GeoData>
00026 
00027 
00028 namespace osgEarth { namespace Features
00029 {
00030     using namespace osgEarth;
00031 
00035     class OSGEARTHFEATURES_EXPORT GriddingPolicy
00036     {
00037     public:
00038         enum CullingTechnique
00039         {
00040             /* crop a feature's shape to the oundaries of the grid cell;
00041                default for lines */
00042             CULL_BY_CROPPING,   
00043 
00044             /* include a feature in the cell only if its centroid is in the cell;
00045                default for polygons and points */
00046             CULL_BY_CENTROID
00047         };
00048 
00049     public: 
00050         GriddingPolicy( const Config& conf =Config() );
00051 
00052         bool enabled() const { return _cellSize.isSet() && *_cellSize > 0.0; }
00053 
00054     public:
00055         virtual Config getConfig() const;
00056         virtual void fromConfig( const Config& conf );
00057 
00058     public: // properties
00059 
00061         optional<double>& cellSize() { return _cellSize; }
00062         const optional<double>& cellSize() const { return _cellSize; }
00063 
00065         optional<CullingTechnique>& cullingTechnique() { return _cullingTechnique; }
00066         const optional<CullingTechnique>& cullingTechnique() const { return _cullingTechnique; }
00067 
00069         optional<bool>& spatializeGroups() { return _spatializeGroups; }
00070         const optional<bool>& spatializeGroups() const { return _spatializeGroups; }
00071 
00073         optional<bool>& clusterCulling() { return _clusterCulling; }
00074         const optional<bool>& clusterCulling() const { return _clusterCulling; }
00075 
00076     protected:
00077         optional<double> _cellSize;
00078         optional<CullingTechnique> _cullingTechnique;
00079         optional<bool> _spatializeGroups;
00080         optional<bool> _clusterCulling;
00081     };
00082 
00088     class OSGEARTHFEATURES_EXPORT FeatureGridder : public osg::Referenced
00089     {
00090     public:
00091         static bool isSupported();
00092 
00093     public:
00094         FeatureGridder( const Bounds& bounds, const GriddingPolicy& policy );
00095 
00096         int getNumCells() const;
00097 
00098         bool getCellBounds( int i, Bounds& output ) const;
00099 
00100         bool cullFeatureListToCell( int i, FeatureList& features ) const;
00101 
00102     public:
00103         virtual ~FeatureGridder();
00104 
00105     protected:
00106         Bounds _inputBounds;
00107         GriddingPolicy _policy;
00108         int _cellsX, _cellsY;
00109         std::list<void*> _geosGeoms;
00110     };
00111 
00112 } } // namespace osgEarth::Features
00113 
00114 #endif //OSGEARTHFEATURES_FEATURE_GRIDDER_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines