This file is indexed.

/usr/include/osgEarth/Terrain is in libosgearth-dev 2.7.0+dfsg-2+b3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
/* -*-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_TERRAIN_H
#define OSGEARTH_TERRAIN_H 1

#include <osgEarth/Common>
#include <osgEarth/TileKey>
#include <osgEarth/ThreadingUtils>
#include <osgEarth/TerrainOptions>
#include <osg/OperationThread>
#include <osg/View>

namespace osgEarth
{
    class Terrain;
    class SpatialReference;

    /**
     * This object is passed to terrain callbacks to provide context information
     * and a feedback interface to terrain callback consumers.
     */
    class TerrainCallbackContext
    {
    public:
        const Terrain* getTerrain() const { return _terrain; }

        /** Indicate that the callback should be removed immediately */
        void remove() { _remove = true; }

        /** whether the user called remove(). */
        bool markedForRemoval() const { return _remove; }

        
    public:
        TerrainCallbackContext(Terrain* terrain)
            : _remove(false), _terrain(terrain) { }

        /** dtor */
        virtual ~TerrainCallbackContext() { }

    protected:
        bool _remove;
        Terrain* _terrain;
        friend class Terrain;
    };


    /**
     * Callback that you can register with the Terrain in order to receive
     * update messaged about the terrain scene graph.
     */
    class TerrainCallback : public osg::Referenced
    {
    public:
        /**
         * A tile was added to the terrain graph.
         * @param key
         *      Tile key of the new tile, including the geographic extents
         * @param tile
         *      Geometry of the new tile
         * @param context
         *      Contextual information about the callback
         */
        virtual void onTileAdded(
            const TileKey&          key, 
            osg::Node*              tile, 
            TerrainCallbackContext& context) { }

        /** dtor */
        virtual ~TerrainCallback() { }
    };


    /**
     * Convenience adapter for hooking a callback into a class. The
     * class must be derived from osg::Referenced. When the class
     * destructs, the callback will automatically remove itself from
     * the Terrain object.
     */
    template<typename T>
    class TerrainCallbackAdapter : public TerrainCallback
    {
    public:
        TerrainCallbackAdapter(T* t) : _t(t) { }
        void onTileAdded(const TileKey&          key, 
                         osg::Node*              tile, 
                         TerrainCallbackContext& context)
        {
            osg::ref_ptr<T> t;
            if (_t.lock(t))
                t->onTileAdded(key, tile, context);
            else
                context.remove();
        }
    protected:
        virtual ~TerrainCallbackAdapter() { }
        osg::observer_ptr<T> _t;
    };


    /**
     * Interface for an object that can resolve the terrain elevation
     * at a given map location.
     */
    class /*interface-only*/ TerrainResolver
    {
    public:
        virtual bool getHeight(
            const SpatialReference* srs,
            double                  x,
            double                  y,
            double*                 out_heightAboveMSL,
            double*                 out_heightAboveEllipsoid =0L) const =0;

        virtual bool getHeight(
            osg::Node*              patch,
            const SpatialReference* srs,
            double                  x,
            double                  y,
            double*                 out_heightAboveMSL,
            double*                 out_heightAboveEllipsoid =0L) const =0;

        /** dtor */
        virtual ~TerrainResolver() { }
    };

    // backwards compatibility
    typedef TerrainResolver TerrainHeightProvider;


    /**
     * Services for interacting with the live terrain graph. This differs from
     * the Map model; Map represents the parametric data backing the terrain, 
     * while Terrain represents the actual geometry in memory.
     *
     * All returned map coordinate values are in the units conveyed in the
     * spatial reference at getSRS().
     */
    class OSGEARTH_EXPORT Terrain : public osg::Referenced, public TerrainResolver
    {
    public:
        /**
         * Gets the profile of the map with which this terrain is associated.
         */
        const Profile* getProfile() const { return _profile.get(); }

        /**
         * Gets the spatial reference of the map with which this terrain is
         * associated.
         */
        const SpatialReference* getSRS() const { return _profile->getSRS(); }

        /**
         * Whether the terrain is in geocentric (ECEF) coordinates
         */
        bool isGeocentric() const { return _geocentric; }


    public: // TerrainResolver interface

        /**
         * Intersects the terrain at the location x, y and returns the height data.
         *
         * @param srs
         *      Spatial reference system of (x,y) coordinates
         * @param x, y
         *      Coordinates at which to query the height
         * @param out_heightAboveMSL
         *      The resulting relative height goes here. The height is relative to MSL
         *      (mean sea level) as expressed by the map's vertical datum.
         * @param out_heightAboveEllipsoid
         *      The resulting geodetic height goes here. The height is relative to the
         *      geodetic ellipsoid expressed by the map's SRS.
         */
        bool getHeight(
            const SpatialReference* srs,
            double                  x,
            double                  y,
            double*                 out_heightAboveMSL,
            double*                 out_heightAboveEllipsoid =0L) const;

        /**
         * Save as above, but specify a subgraph patch.
         */
        bool getHeight(
            osg::Node*              patch,
            const SpatialReference* srs,
            double                  x,
            double                  y,
            double*                 out_heightAboveMSL,
            double*                 out_heightAboveEllipsoid =0L) const;

    public:

        /**
         * Returns the world coordinates under the mouse.
         * @param view
         *      View in which to do the query
         * @param mx, my
         *      Mouse coordinates
         * @param out_coords 
         *      Stores the world coordinates under the mouse (when returning true)
         */
        bool getWorldCoordsUnderMouse(
            osg::View*  view,
            float       mx,
            float       my,
            osg::Vec3d& out_world ) const;

        bool getWorldCoordsUnderMouse(
            osg::View*  view,
            float       mx,
            float       my,
            osg::Vec3d& out_world,
            osg::ref_ptr<osg::Node>& out_node ) const;

    public:
        /**
         * Adds a terrain callback.
         *
         * @param callback
         *      Terrain callback to add. This will get called whenever tile data changes in
         *      the active terrain graph
         */
        void addTerrainCallback( TerrainCallback* callback);

        /**
         * Removes a terrain callback.
         */
        void removeTerrainCallback( TerrainCallback* callback );
        

    public:

        /**
         * Accept a node visitor on the terrain's scene graph.
         */
        void accept( osg::NodeVisitor& nv );

        // access the raw terrain graph
        osg::Node* getGraph() { return _graph.get(); }
        
        // queues the onTileAdded callback (internal)
        void notifyTileAdded( const TileKey& key, osg::Node* tile );
        // fires the onTileAdded callback (internal)
        void fireTileAdded( const TileKey& key, osg::Node* tile );

        // queues the onTileRemoved callback (internal)
        void notifyTilesRemoved(const std::vector<TileKey>& keys);
        void fireTilesRemoved(const std::vector<TileKey>& keys);

        /** dtor */
        virtual ~Terrain() { }

    private:
        Terrain( osg::Node* graph, const Profile* profile, bool geocentric, const TerrainOptions& options );

        friend class TerrainEngineNode;

        typedef std::list< osg::ref_ptr<TerrainCallback> > CallbackList;

        CallbackList                 _callbacks;
        Threading::ReadWriteMutex    _callbacksMutex;
        OpenThreads::Atomic          _callbacksSize; // separate size tracker for MT size check w/o a lock

        osg::ref_ptr<const Profile>  _profile;
        osg::observer_ptr<osg::Node> _graph;
        bool                         _geocentric;
        const TerrainOptions&        _terrainOptions;

        osg::observer_ptr<osg::OperationQueue> _updateOperationQueue;
    };


    /**
     * A TerrainPatch is a standalone subset of terrain that you can use for 
     * height queries. The intention is that this be used for a "disconnected"
     * terrain tile, i.e. one that is not in the scene graph yet -- making it
     * MT-safe.
     */
    class OSGEARTH_EXPORT TerrainPatch : public TerrainResolver
    {
    public:
        TerrainPatch( osg::Node* patch, const Terrain* terrain );


    public: // TerrainResolver interface

        /**
        * Queries the elevation under the specified point. This method is
        * identical to calling Terrain::getHeight with the specified patch.
        */
        bool getHeight(
            const SpatialReference* srs,
            double                  x,
            double                  y,
            double*                 out_heightAboveMSL,
            double*                 out_heightAboveEllipsoid =0L) const;

    protected:
        osg::ref_ptr<osg::Node>     _patch;
        osg::ref_ptr<const Terrain> _terrain;
    };
}

#endif // OSGEARTH_COMPOSITING_H