osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthDrivers/engine_seamless/QSC

Go to the documentation of this file.
00001 /* -*-c++-*- */
00002 /* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
00003  * Copyright 2010 Pelican Ventures, Inc.
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 SEAMLESS_QSC
00021 #define SEAMLESS_QSC 1
00022 
00023 #include <osgEarth/Common>
00024 #include <osgEarth/Profile>
00025 #include <osgEarth/TileKey>
00026 #include <osgEarth/Locators>
00027 
00028 namespace seamless
00029 {
00043 namespace qsc
00044 {
00045 extern bool latLonToFaceCoords(
00046     double lat_deg, double lon_deg, double& out_x, double& out_y, int& out_face,
00047     int faceHint = -1);
00048 
00052 extern bool faceCoordsToLatLon(
00053     double x, double y, int face,
00054     double& out_lat_deg, double& out_lon_deg);
00055 
00062 extern bool cubeToFace(
00063     double& in_out_x, double& in_out_y,int& out_face);
00064 
00070 extern bool cubeToFace(
00071     double& in_out_xmin, double& in_out_ymin,
00072     double& in_out_xmax, double& in_out_ymax,
00073     int& out_face);
00074 
00078 extern bool faceToCube(
00079     double& in_out_x, double& in_out_y, int face);
00080 }
00081 
00086 class QscFaceLocator : public osgEarth::GeoLocator
00087 {
00088 public:
00089     QscFaceLocator(unsigned int face)
00090         : _face(face)
00091     {
00092     }
00093 
00094     // This method will generate geocentric vertex coordinates, given local tile
00095     // coordinates (0=>1).
00096     bool convertLocalToModel(const osg::Vec3d& local, osg::Vec3d& world) const;
00097 
00098     // This method will generate the texture coordinates for a given location on
00099     // the globe.
00100     bool convertModelToLocal(const osg::Vec3d& world, osg::Vec3d& local) const;
00101 
00102 private:
00103     unsigned int _face;
00104 };
00105 
00113 class QscSpatialReference : public osgEarth::SpatialReference
00114 {
00115 public:
00116     QscSpatialReference(void* handle);
00117 
00118     virtual osgEarth::GeoLocator* createLocator(
00119         double xmin, double ymin, double xmax, double ymax,
00120         bool plate_carre =false) const;
00121 
00122     // Qsc is a projected coordinate system.
00123     virtual bool isGeographic() const { return false; }
00124     virtual bool isProjected() const { return true; }
00125 
00126     // This SRS uses a WGS84 lat/long SRS under the hood for reprojection. So we need the
00127     // pre/post transforms to move from cube to latlong and back.
00128     virtual bool preTransform(double& x, double& y, void* context) const;
00129     virtual bool postTransform(double& x, double& y, void* context) const;
00130 
00131     virtual bool transformExtent(
00132         const SpatialReference* to_srs,
00133         double& in_out_xmin,
00134         double& in_out_ymin,
00135         double& in_out_xmax,
00136         double& in_out_ymax,
00137         void* context) const;
00138 
00139 protected: // SpatialReference overrides
00140 
00141     void _init();
00142 
00143 };
00144 
00145 class QscProfile : public osgEarth::Profile
00146 {
00147 public:
00148     QscProfile();
00149 
00150 public: // utilities
00151 
00155     static int getFace( const osgEarth::TileKey* key );
00156 
00157 public: // Profile
00158 
00159     virtual void getIntersectingTiles(
00160         const osgEarth::GeoExtent& extent,
00161         std::vector<osgEarth::TileKey>& out_intersectingKeys ) const;
00162 
00163 private:
00164 
00165 };
00166 }
00167 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines