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 00020 #ifndef OSGEARTH_LOCATORS_H 00021 #define OSGEARTH_LOCATORS_H 1 00022 00023 #include <osgEarth/Common> 00024 #include <osgEarth/GeoData> 00025 #include <osgTerrain/Locator> 00026 00027 namespace osgEarth 00028 { 00034 class OSGEARTH_EXPORT GeoLocator : public osgTerrain::Locator 00035 { 00036 public: 00037 GeoLocator(); 00038 00039 GeoLocator( const GeoExtent& dataExtent ); 00040 00041 GeoLocator( const osgTerrain::Locator& prototype, const GeoExtent& dataExtent ); 00042 00044 GeoLocator( const osgTerrain::Locator& prototype, const GeoExtent& dataExtent, const GeoExtent& displayExtent ); 00045 00046 static GeoLocator* createForKey( const class TileKey& key, const class MapInfo& mapInfo ); 00047 static GeoLocator* createForExtent( const GeoExtent& extent, const class MapInfo& mapInfo); 00048 00049 void setDataExtent( const GeoExtent& extent ); 00050 const GeoExtent& getDataExtent() const; 00051 00053 virtual GeoLocator* cloneAndCrop( const osgTerrain::Locator& prototype, const GeoExtent& displayExtent ) const; 00054 00055 virtual GeoLocator* getGeographicFromGeocentric( ) const; 00056 00057 virtual bool isEquivalentTo( const GeoLocator& rhs ) const; 00058 00059 public: // Locator 00060 virtual bool convertModelToLocal(const osg::Vec3d& world, osg::Vec3d& local) const; 00061 00062 protected: 00063 void cropLocal( osg::Vec3d& local ) const; 00064 00065 bool _inverseCalculated; 00066 00067 private: 00068 GeoExtent _dataExtent; 00069 double _x0, _y0, _x1, _y1; 00070 }; 00071 00072 00079 class OSGEARTH_EXPORT MercatorLocator : public GeoLocator 00080 { 00081 public: 00082 MercatorLocator( const osgTerrain::Locator& prototype, const GeoExtent& dataExtent ); 00083 00084 //virtual bool convertLocalToModel(const osg::Vec3d& local, osg::Vec3d& model) const; 00085 virtual bool convertModelToLocal(const osg::Vec3d& world, osg::Vec3d& local) const; 00086 00088 virtual GeoLocator* cloneAndCrop( const osgTerrain::Locator& prototype, const GeoExtent& displayExtent ); 00089 00090 virtual GeoLocator* getGeographicFromGeocentric( ); 00091 00092 private: 00093 GeoExtent _geoDataExtent; 00094 }; 00095 } 00096 00097 #endif // OSGEARTH_LOCATORS_H