/usr/include/osgEarthUtil/TerrainProfile is in libosgearth-dev 2.9.0+dfsg-1.
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 | /* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2016 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.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* 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 OSGEARTHUTIL_TERRAINPROFILE
#define OSGEARTHUTIL_TERRAINPROFILE
#include <osgEarthUtil/Common>
#include <osgEarth/Terrain>
#include <osgSim/ElevationSlice>
namespace osgEarth {
class MapNode;
}
namespace osgEarth { namespace Util {
/**
* Stores the results of a terrain profile calculation
*/
class OSGEARTHUTIL_EXPORT TerrainProfile
{
public:
/**
* Create a new TerrainProfile
*/
TerrainProfile();
/**
* Copy constructor
*/
TerrainProfile(const TerrainProfile& profile);
/** dtor */
virtual ~TerrainProfile() { }
/**
* Gets the distance at the given index
* @param i
* The index of the profile measurement
*/
double getDistance( int i ) const;
/**
* Gets the total distance covered by this TerrainProfile
*/
double getTotalDistance() const;
/**
* Gets the min and max elevations of this TerrainProfile
* @param min
* The minimum elevation in meters of this TerrainProfile
* @param max
* The maximum elevation in meters of this TerrainProfile
*/
void getElevationRanges(double &min, double &max ) const;
/**
* Gets the elevation at the given index
* @param i
* The index of the profile measurement
*/
double getElevation( int i ) const;
/**
* Gets the number of elevation measurements in this TerrainProfile
*/
unsigned int getNumElevations() const;
/**
* Add an elevation measurement to this TerrainProfile
*/
void addElevation( double distance, double elevation );
/**
* Clears all measurements from this TerrainProfile
*/
void clear();
private:
double _spacing;
typedef std::pair<double,double> DistanceHeight;
typedef std::vector<DistanceHeight> DistanceHeightList;
DistanceHeightList _elevations;
};
/**
* Computes a TerrainProfile between two points. Monitors the scene graph for changes
* to elevation and updates the profile.
*/
class OSGEARTHUTIL_EXPORT TerrainProfileCalculator : public TerrainCallback
{
public:
/**
* Callback that is fired when the profile changes
*/
struct ChangedCallback : public osg::Referenced
{
public:
virtual void onChanged(const TerrainProfileCalculator* sender) {};
virtual ~ChangedCallback() { }
};
typedef std::list< osg::observer_ptr<ChangedCallback> > ChangedCallbackList;
/**
* Creates a new TerrainProfileCalculator
* @param mapNode
* The MapNode to compute the terrain profile against
* @param start
* The start point of the profile
* @param end
* The end point of the profile
*/
TerrainProfileCalculator(osgEarth::MapNode* mapNode, const osgEarth::GeoPoint& start, const osgEarth::GeoPoint& end);
/**
* Creates a new TerrainProfileCalculator
* @param mapNode
* The MapNode to compute the terrain profile against
*/
TerrainProfileCalculator(osgEarth::MapNode* mapNode);
/** dtor */
virtual ~TerrainProfileCalculator();
/**
* Set the MapNode to compute the terrain profile against
*/
void setMapNode( osgEarth::MapNode* mapNode );
/**
* Add a ChangedCallback
*/
void addChangedCallback( ChangedCallback* callback );
/**
* Remove a ChangedCallback
*/
void removeChangedCallback( ChangedCallback* callback );
/**
* Gets the computed TerrainProfile
*/
const TerrainProfile& getProfile() const;
/**
* Gets the start point of the terrain profile
*/
const GeoPoint& getStart() const;
/**
* Gets the start point of the terrain profile
*/
GeoPoint getStart(AltitudeMode altMode) const;
/**
* Gets the end point of the terrain profile
*/
const GeoPoint& getEnd() const;
/**
* Gets the end point of the terrain profile
*/
GeoPoint getEnd(AltitudeMode altMode) const;
/**
* Sets the start and end points of the terrain profile
*/
void setStartEnd(const osgEarth::GeoPoint& start, const osgEarth::GeoPoint& end);
virtual void onTileAdded(const osgEarth::TileKey& tileKey, osg::Node* graph, TerrainCallbackContext&);
/**
* Recomputes the terrain profile
*/
void recompute();
/**
* Utility to directly compute a terrain profile
* @param mapNode
* The MapNode to compute the terrain profile one
* @param start
* The start point of the terrain profile
* @param end
* The end point of the terrain profile
* @param numSamples
* The number of samples to compute
* @param profile
* The resulting TerrainProfile
*/
static void computeTerrainProfile( osgEarth::MapNode* mapNode, const osgEarth::GeoPoint& start, const osgEarth::GeoPoint& end, TerrainProfile& profile);
private:
osgEarth::GeoPoint _start;
osgEarth::GeoPoint _end;
TerrainProfile _profile;
osg::ref_ptr< osgEarth::MapNode > _mapNode;
ChangedCallbackList _changedCallbacks;
};
} } // namespace osgEarth::Util
#endif // OSGEARTHUTIL_TERRAINPROFILE
|