~ubuntu-branches/debian/sid/osgearth/sid

« back to all changes in this revision

Viewing changes to src/osgEarth/Locators

  • Committer: Bazaar Package Importer
  • Author(s): Pirmin Kalberer
  • Date: 2011-07-14 22:13:36 UTC
  • Revision ID: james.westby@ubuntu.com-20110714221336-94igk9rskxveh794
Tags: upstream-2.0+dfsg
ImportĀ upstreamĀ versionĀ 2.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*-c++-*- */
 
2
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
 
3
 * Copyright 2008-2010 Pelican Mapping
 
4
 * http://osgearth.org
 
5
 *
 
6
 * osgEarth is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU Lesser General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU Lesser General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU Lesser General Public License
 
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 
18
 */
 
19
 
 
20
#ifndef OSGEARTH_LOCATORS_H
 
21
#define OSGEARTH_LOCATORS_H 1
 
22
 
 
23
#include <osgEarth/Common>
 
24
#include <osgEarth/GeoData>
 
25
#include <osgTerrain/Locator>
 
26
 
 
27
namespace osgEarth
 
28
{
 
29
    /**
 
30
     * Locator that stores the extent of its source data (which might be different
 
31
     * than the extent of the locator's transform). This locator can also automatically
 
32
     * crop out a section of the source image.
 
33
     */
 
34
    class OSGEARTH_EXPORT GeoLocator : public osgTerrain::Locator
 
35
    {
 
36
    public:
 
37
        GeoLocator();
 
38
 
 
39
        GeoLocator( const GeoExtent& dataExtent );
 
40
 
 
41
        GeoLocator( const osgTerrain::Locator& prototype, const GeoExtent& dataExtent );
 
42
 
 
43
        /** Construct a locator that crops to a display extent. */
 
44
        GeoLocator( const osgTerrain::Locator& prototype, const GeoExtent& dataExtent, const GeoExtent& displayExtent );
 
45
 
 
46
        static GeoLocator* createForKey( const class TileKey& key, const class MapInfo& mapInfo );
 
47
 
 
48
        void setDataExtent( const GeoExtent& extent );
 
49
        const GeoExtent& getDataExtent() const;
 
50
 
 
51
        /** Clones the current locator, applying a new display (i.e. crop) extent. */
 
52
        virtual GeoLocator* cloneAndCrop( const osgTerrain::Locator& prototype, const GeoExtent& displayExtent ) const;
 
53
 
 
54
        virtual GeoLocator* getGeographicFromGeocentric( ) const;
 
55
 
 
56
        virtual bool isEquivalentTo( const GeoLocator& rhs ) const;
 
57
        
 
58
    public: // Locator
 
59
        virtual bool convertModelToLocal(const osg::Vec3d& world, osg::Vec3d& local) const;
 
60
 
 
61
    protected:
 
62
        void cropLocal( osg::Vec3d& local ) const;
 
63
 
 
64
        bool _inverseCalculated;
 
65
 
 
66
    private:
 
67
        GeoExtent _dataExtent;
 
68
        double _x0, _y0, _x1, _y1;
 
69
    };
 
70
 
 
71
    
 
72
    /**
 
73
     * A terrain locator that generates texture coordinates that warp a Mercator image.
 
74
     *
 
75
     * Note: the MercatorLocator doesn't have a "cropping" variation b/c it automatically
 
76
     * self-crops as necessary.
 
77
     */
 
78
    class OSGEARTH_EXPORT MercatorLocator : public GeoLocator
 
79
    {
 
80
    public:
 
81
        MercatorLocator( const osgTerrain::Locator& prototype, const GeoExtent& dataExtent );
 
82
 
 
83
        //virtual bool convertLocalToModel(const osg::Vec3d& local, osg::Vec3d& model) const;
 
84
        virtual bool convertModelToLocal(const osg::Vec3d& world, osg::Vec3d& local) const;
 
85
        
 
86
        /** Clones the current locator, applying a new display (i.e. crop) extent. */
 
87
        virtual GeoLocator* cloneAndCrop( const osgTerrain::Locator& prototype, const GeoExtent& displayExtent );
 
88
 
 
89
        virtual GeoLocator* getGeographicFromGeocentric( );
 
90
 
 
91
    private:
 
92
        GeoExtent _geoDataExtent;
 
93
    };
 
94
}
 
95
 
 
96
#endif // OSGEARTH_LOCATORS_H