1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2015 Pelican Mapping
* http://osgearth.org
*
* osgEarth is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef OSGEARTH_GEO_TRANSFORM
#define OSGEARTH_GEO_TRANSFORM
#include <osgEarth/Common>
#include <osgEarth/Config>
#include <osgEarth/GeoData>
#include <osgEarth/Terrain>
#include <osg/MatrixTransform>
namespace osgEarth
{
class TileKey;
/**
* Transform node that accepts geospatial coordinates.
*/
class OSGEARTH_EXPORT GeoTransform : public osg::MatrixTransform
{
public:
META_Node(osgEarth, GeoTransform);
/** Constructor */
GeoTransform();
/** Copy constructor */
GeoTransform(const GeoTransform& rhs, const osg::CopyOp& op);
/**
* Sets the geospatial position. Returns false upon error.
* This method will only handle a GeoPoint with ALTMODE_ABSOLUTE.
*/
bool setPosition(const GeoPoint& p);
/**
* Gets the last known geospatial position.
*/
const GeoPoint& getPosition() const;
/**
* Sets a reference terrain for this transform. Setting this
* is required if you want to transform positions into the
* terrain's SRS or if you want support for ALTMODE_RELATIVE
* positions.
*/
void setTerrain(Terrain* terrain);
/**
* Enabling this will cause the object to automatically
* recompute the matrix for an ALTMODE_RELATIVE position if
* the terrain under that position changes. This is disabled
* by default. This functionality requires that you set
* a reference terrain (see setTerrain).
*/
void setAutoRecomputeHeights(bool value);
public: // TerrainCallback interface
// called when new data pages in and autoRecompute is true
void onTileAdded(const TileKey& key,
osg::Node* node,
TerrainCallbackContext& context);
protected:
virtual ~GeoTransform() { }
GeoPoint _position;
osg::observer_ptr<Terrain> _terrain;
bool _autoRecompute;
bool _autoRecomputeReady;
void configureAutoRecompute(Terrain* terrain);
};
} // namespace osgEarth
#endif // OSGEARTH_GEO_TRANSFORM