osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarth/Profile

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 OSGEARTH_TILE_GRID_PROFILE_H
00021 #define OSGEARTH_TILE_GRID_PROFILE_H 1
00022 
00023 #include <osgEarth/Common>
00024 #include <osgEarth/Config>
00025 #include <osgEarth/GeoData>
00026 #include <osgEarth/SpatialReference>
00027 #include <osgEarth/VerticalSpatialReference>
00028 #include <osg/CoordinateSystemNode>
00029 #include <vector>
00030 
00031 namespace osgEarth
00032 {
00033     class TileKey;
00034 
00038     class OSGEARTH_EXPORT ProfileOptions : public ConfigOptions
00039     {
00040     public:
00041         ProfileOptions( const ConfigOptions& options =ConfigOptions() );
00042         ProfileOptions( const std::string& namedProfile );
00043 
00045         bool defined() const;
00046 
00047     public: // properties
00048 
00050         optional<std::string>& namedProfile() { return _namedProfile; }
00051         const optional<std::string>& namedProfile() const { return _namedProfile; }
00052 
00054         optional<std::string>& srsString() { return _srsInitString; }
00055         const optional<std::string>& srsString() const { return _srsInitString; }
00056 
00058         optional<std::string>& vsrsString() { return _vsrsInitString; }
00059         const optional<std::string>& vsrsString() const { return _vsrsInitString; }
00060 
00062         optional<Bounds>& bounds() { return _bounds; }
00063         const optional<Bounds>& bounds() const { return _bounds; }
00064 
00066         optional<int>& numTilesWideAtLod0() { return _numTilesWideAtLod0; }
00067         const optional<int>& numTilesWideAtLod0() const { return _numTilesWideAtLod0; }
00068 
00070         optional<int>& numTilesHighAtLod0() { return _numTilesHighAtLod0; }
00071         const optional<int>& numTilesHighAtLod0() const { return _numTilesHighAtLod0; }
00072 
00073     public:
00074         Config getConfig() const;
00075 
00076     protected:
00077         void mergeConfig( const Config& conf ) {
00078             ConfigOptions::mergeConfig( conf );
00079             fromConfig( conf );
00080         }
00081 
00082     private:
00083         void fromConfig( const Config& conf );
00084 
00085         optional<std::string> _namedProfile;
00086         optional<std::string> _srsInitString;
00087         optional<std::string> _vsrsInitString;
00088         optional<Bounds>      _bounds;
00089         optional<int>         _numTilesWideAtLod0;
00090         optional<int>         _numTilesHighAtLod0;
00091     };
00092 
00098     class OSGEARTH_EXPORT Profile : public osg::Referenced
00099     {
00100     public:
00101         // profile types:
00102         enum ProfileType
00103         {
00104             TYPE_UNKNOWN,
00105             TYPE_GEODETIC,
00106             TYPE_MERCATOR,
00107             TYPE_LOCAL
00108         };
00109 
00110     public:
00111 
00112         static const Profile* create(
00113             const std::string& srs_string,
00114             double xmin, double ymin, double xmax, double ymax,
00115             const std::string& vsrs_string ="",
00116             unsigned int numTilesWideAtLod0 =0,
00117             unsigned int numTilesHighAtLod0 =0 );
00118 
00119         static const Profile* create(
00120             const SpatialReference* srs,
00121             double xmin, double ymin, double xmax, double ymax,
00122             double geoxmin, double geoymin, double geoxmax, double geoymax,
00123             const VerticalSpatialReference* vsrs =0L,
00124             unsigned int numTilesWideAtLod0 =0,
00125             unsigned int numTilesHighAtLod0 =0 );
00126 
00127         static const Profile* create(
00128             const SpatialReference* srs,
00129             double xmin, double ymin, double xmax, double ymax,
00130             const VerticalSpatialReference* vsrs =0L,
00131             unsigned int numTilesWideAtLod0 =0,
00132             unsigned int numTilesHighAtLod0 =0 );
00133 
00134         static const Profile* create(
00135             const std::string& srs_string,
00136             const std::string& vsrs_string ="",
00137             unsigned int numTilesWideAtLod0 =0,
00138             unsigned int numTilesHighAtLod0 =0 );
00139 
00140         static const Profile* create(
00141             const ProfileOptions& options );
00142 
00146         bool isOK() const;
00147 
00151         const GeoExtent& getExtent() const;
00152 
00156         const GeoExtent& getLatLongExtent() const;
00157         
00161         const SpatialReference* getSRS() const;
00162 
00166         const VerticalSpatialReference* getVerticalSRS() const { return _vsrs.get(); }
00167         void setVerticalSRS( const VerticalSpatialReference* value ) { _vsrs = value; }
00168 
00172         ProfileType getProfileType() const;  
00173 
00178         unsigned int getLevelOfDetailForHorizResolution( double resolution, int tileSize ) const;
00179 
00184         void getRootKeys(std::vector<TileKey>& out_keys ) const;
00185 
00189         virtual GeoExtent calculateExtent( unsigned int lod, unsigned int tileX, unsigned int tileY );
00190 
00194         static ProfileType getProfileTypeFromSRS(const std::string &srs);
00195 
00199         bool isEquivalentTo( const Profile* rhs ) const;
00200 
00204         void getTileDimensions(unsigned int lod, double& out_width, double& out_height) const;
00205 
00209         void getNumTiles(unsigned int lod, unsigned int& out_tiles_wide, unsigned int& out_tiles_high) const;
00210 
00214         void getIntersectingTiles(
00215             const TileKey& key,
00216             std::vector<TileKey>& out_intersectingKeys) const;
00217 
00221         virtual void getIntersectingTiles(
00222             const GeoExtent& extent,
00223             std::vector<TileKey>& out_intersectingKeys) const;
00224 
00230         GeoExtent clampAndTransformExtent( const GeoExtent& input, bool* out_clamped =0L ) const;
00231 
00237         TileKey createTileKey( double x, double y, unsigned int level ) const;
00238 
00242         std::string toString() const;
00243 
00244     protected:       
00245 
00246         Profile(
00247             const SpatialReference* srs,
00248             double xmin, double ymin, double xmax, double ymax,
00249             const VerticalSpatialReference* vsrs,
00250             unsigned int x_tiles_at_lod0 =0,
00251             unsigned int y_tiles_at_lod0 =0 );      
00252 
00253         Profile(
00254             const SpatialReference* srs,
00255             double xmin, double ymin, double xmax, double ymax,
00256             double geoxmin, double geoymin, double geoxmax, double geoymax,
00257             const VerticalSpatialReference* vsrs,
00258             unsigned int x_tiles_at_lod0 =0,
00259             unsigned int y_tiles_at_lod0 =0 );
00260         
00261 
00262         virtual void addIntersectingTiles(
00263             const GeoExtent& key_ext,
00264             std::vector<TileKey>& out_intersectingKeys) const;
00265 
00266 
00267     private:
00268 
00269         GeoExtent _extent;
00270         GeoExtent _latlong_extent;
00271         osg::ref_ptr<const VerticalSpatialReference> _vsrs;
00272         unsigned int _numTilesWideAtLod0;
00273         unsigned int _numTilesHighAtLod0;
00274     };
00275 }
00276 
00277 #endif // OSGEARTH_TILE_GRID_PROFILE_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines