GL Studio C++ Runtime API
gls_map_dted.h
Go to the documentation of this file.
1 /*! \file
2  \brief The DTEDMapChartDataSource class header
3 
4  \par Copyright Information
5 
6  Copyright (c) 2017 The DiSTI Corporation.<br>
7  11301 Corporate Blvd; Suite 100<br>
8  Orlando, Florida 32817<br>
9  USA<br>
10  <br>
11  All rights reserved.<br>
12 
13  This Software contains proprietary trade secrets of DiSTI and may not be
14 reproduced, in whole or part, in any form, or by any means of electronic,
15 mechanical, or otherwise, without the written permission of DiSTI. Said
16 permission may be derived through the purchase of applicable DiSTI product
17 licenses which detail the distribution rights of this content and any
18 Derivative Works based on this or other copyrighted DiSTI Software.
19 
20  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26 
27  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34 EXCEED FIVE DOLLARS (US$5.00).
35 
36  The aforementioned terms and restrictions are governed by the laws of the
37 State of Florida and the United States of America.
38 
39 */
40 #ifndef INCLUDED_GLS_MAP_DTED_H
41 #define INCLUDED_GLS_MAP_DTED_H
42 
43 #include "gls_color.h"
44 #include <string>
45 
47 
48 #define LIB_BASE_NAME "gls_map_dted"
49 #include "gls_auto_lib.h"
50 #undef LIB_BASE_NAME
51 
52 // The 'null' value for elevation data; this denotes an invalid or missing data point in the dted
53 // file.
54 #define DTED_NULL_ELEVATION_VALUE -32767
55 
56 namespace disti
57 {
58 class DTEDElevationDataStore;
59 class DTEDMapChartCellManager;
60 class DTEDFileLoadThread;
61 class DTEDCalcParamsStore;
62 class DTEDWorkerThreadManager;
63 class DTEDShaderManager;
64 
65 /// \defgroup ds_DTED DTED
66 /// DTED data source
67 
68 /** Runtime implementation of a DTEDMapChartDataSource
69  * \ingroup ds_DTED
70  * @{
71  */
73 {
74 public:
75  /** Constructor */
77  /** Destructor */
78  virtual ~DTEDMapChartDataSource();
79 
80  // GlsMapChartDataSource inherited methods
81 
82  /** \sa GlsMapChartDataSource */
83  virtual bool GetAvailableCoverage( GeoRect* dest ) DISTI_METHOD_OVERRIDE;
84  /** \sa GlsMapChartDataSource */
85  void GetCellList( const GeoRect& coverage, unsigned long layerID, double viewLogicalHeight, double viewGeoHeight, MapChartCellList& viewList ) DISTI_METHOD_OVERRIDE;
86  /** \sa GlsMapChartDataSource */
87  virtual bool AreAllCellsLoaded( GlsMapView* view, GlsMapChart* chart ) DISTI_METHOD_OVERRIDE;
88 
89  // Source data file specification
90 
91  /**
92  * Reads in a single DTED file and adds its data to the data source.
93  * \param filename The path and name of the file to be read in
94  */
95  void AddDataFile( const std::string& filename );
96 
97  /**
98  * Reads in all compatble DTED files within the specified directory and adds their data to
99  * the data source.
100  * \param directory The path of the directory containing the files to be read in
101  * \param recurse true if the file search should decend into child directories, false
102  * otherwise
103  */
104  void AddAllFiles( const std::string& directory, bool recurse );
105 
106  // Utility functions
107 
108  /**
109  * Retrieves one data point from the currently loaded data.
110  * Performs interpolation if the requested location is between data points.
111  * \param latDegs The latitude of the height data point to retrieve, in degrees
112  * \param lonDegs The longitude of the height data point to retrieve, in degrees
113  * \return The terrain height at the specified location, or DTED_NULL_ELEVATION_VALUE if
114  * no data is available for that location.
115  */
116  short GetElevationDataPoint( double latDegs, double lonDegs );
117 
118  /**
119  * Retrieves one data point from the currently loaded data.
120  * Performs interpolation if the requested location is between data points.
121  * \param coord The GeoCoord structure containing the location of the data point
122  * \return The terrain height at the specified location, or DTED_NULL_ELEVATION_VALUE if
123  * no data is available for that location.
124  */
125  short GetElevationDataPoint( GeoCoord coord );
126 
127  // Special configuration
128 
129  /**
130  * Sets the current height of the aircraft for use in the elevation banding and threat
131  * region rendering. This value is measured in meters above sea level. Negative height
132  * values represent elevations below sea level.
133  * \param aircraftHeight The current height of the aircraft
134  */
135  void SetAircraftHeight( short aircraftHeight );
136 
137  // Diffuse Terrain layer configuration
138 
139  /** Enables or disables rendering of the diffuse shaded terrain.
140  * \param enabled true if terrain should be rendered shaded, false if it should not
141  */
142  void SetDiffuseTerrainLayerEnabled( bool enabled );
143 
144  /** Sets the direction of the light (not position) used in the diffuse terrain layer.
145  * \param x The X value of the direction vector.
146  * \param y The Y value of the direction vector.
147  * \param z The Z value of the direction vector.
148  */
149  void SetDiffuseTerrainLayerLightDirection( float x, float y, float z );
150 
151  /**
152  * Sets the transparency for the diffuse terrain.
153  * \param alpha The terrain's alpha color component. 0-255 range.
154  */
155  void SetDiffuseTerrainLayerTransparency( unsigned char alpha );
156 
157  // Height Terrain layer configuration
158 
159  /**
160  * Enables or disables rendering of the height terrain.
161  * \param enabled true if terrain should be rendered, false if it should not
162  */
163  void SetTerrainLayerEnabled( bool enabled );
164 
165  /**
166  * Sets the intensity range for the terrain. The brightness of the terrain pixels will
167  * always be within this range. Mapping of terrain elevation values to grayscale
168  * intensity values is performed using linear interpolation, with the low and high
169  * elevation values mapped to the low and high intensity values, respectively.
170  * \param lowValue The lowest intensity value used to render the terrain. Must be at
171  * least 1.
172  * \param highValue The highest intensity value used to render the terrain. Must be
173  * greater than or equal to the low value.
174  */
175  void SetTerrainLayerIntensityRange( unsigned char lowValue, unsigned char highValue );
176 
177  /**
178  * Sets the elevation range for the terrain. Elevation values outside of this range are
179  * clamped to the nearest value within the range. Mapping of terrain elevation values to
180  * grayscale intensity values is performed using linear interpolation, with the low and
181  * high elevation values mapped to the low and high intensity values, respectively.
182  * \param lowValue The elevation lower limit value.
183  * \param highValue The elevation upper limit value. Must be greater than or equal to the
184  * low value.
185  */
186  void SetTerrainLayerElevationRange( short lowValue, short highValue );
187 
188  /**
189  * Sets the transparency for the height terrain.
190  * \param alpha The terrain's alpha color component. 0-255 range.
191  */
192  void SetTerrainLayerTransparency( unsigned char alpha );
193 
194  /**
195  * Enables or disables water rendering mode. If enabled, all elevation values at or below
196  * sea level (elevation zero) are considered to be 'water', and are rendered using the
197  * water color.
198  * \param enabled true if water mode should be enabled, false if disabled
199  */
200  void SetTerrainLayerWaterEnabled( bool enabled );
201 
202  /**
203  * Sets the color of the water for water rendering mode. If water rendering mode is
204  * enabled, all elevation values at or below sea level (elevation zero) are considered to
205  * be 'water' and are rendered using this color. This is set for both height and diffuse terrain.
206  * \param waterColor The color to use for rendering water
207  */
208  void SetTerrainLayerWaterColor( const glsColor& waterColor );
209 
210  // Terrain Elevation Banding configuration
211 
212  /**
213  * Enables or disables rendering of the Terrain Elevation Banding.
214  * \param enabled true if banding should be rendered, false if it should not
215  */
216  void SetBandingLayerEnabled( bool enabled );
217 
218  /**
219  * Sets the number of bands to use in the elevation banding rendering.
220  * \param numberOfBands The number of elevation bands. Must be in the range 1 - 16,
221  * inclusive.
222  */
223  void SetBandingLayerBandCount( unsigned int numberOfBands );
224 
225  /**
226  * Sets the render color of one of the terrain elevation bands.
227  * \param bandIndex The zero-based index of the band to set the color of. Must be in the
228  * range 0 - 15.
229  * \param bandColor The color to use when rendering the specified elevation band.
230  */
231  void SetBandingLayerBandColor( unsigned int bandIndex, const glsColor& bandColor );
232 
233  /**
234  * Sets the 'distance' for one of the terrain elevation bands. This value represents the
235  * number of meters between the low and high boundaries for the elevation band. (Or, in
236  * the case of the top elevation band, the number of meters between the bottom of the band
237  * and the aircraft height.)
238  * \param bandIndex The zero-based index of the band to set the distance of. Must be in
239  * the range 0 - 15.
240  * \param bandDistance The band's distance value, measured in meters.
241  */
242  void SetBandingLayerBandDistance( unsigned int bandIndex, unsigned short bandDistance );
243 
244  // Elevation Contour Lines configuration
245 
246  /**
247  * Enables or disables rendering of the Terrain Contour Lines.
248  * \param enabled true if contour lines should be rendered, false if they should not
249  */
250  void SetContourLayerEnabled( bool enabled );
251 
252  /**
253  * Sets the draw priority of the contour lines. If this value is set to true, the contour
254  * lines are drawn on top of all other map elements. If false, the contour lines are drawn
255  * on top of the terrain but underneath the elevation banding and threat regions.
256  * \param drawOnTop true to draw contour lines on top, false otherwise
257  */
258  void SetContourLayerDrawPriority( bool drawOnTop );
259 
260  /**
261  * Sets the elevation interval for the contour lines, in meters. A contour line is
262  * rendered wherever the terrain elevation crosses any integer multiple of this value.
263  * \param interval The interval distance, in meters. Must be at least 1.
264  */
265  void SetContourLayerInterval( unsigned short interval );
266 
267  /**
268  * Sets the render color for the contour lines.
269  * \param lineColor The color to use when rendering contour lines
270  */
271  void SetContourLayerLineColor( const glsColor& lineColor );
272 
273  /**
274  * Sets the thickness of the rendered contour lines, in pixels.
275  * \param lineThickness The contour line thickness in pixels
276  */
277  void SetContourLayerLineThickness( unsigned char lineThickness );
278 
279  /**
280  * Sets the 'quality' of the contour lines. If this value is false, contour lines are only
281  * drawn at elevation data point boundaries. If this value is true, bilinear interpolation
282  * is used to calculate contour lines within the elevation point boundaries.
283  * \param highQuality true to use interpolation for contour lines, false otherwise
284  */
285  void SetContourLayerHighQuality( bool highQuality );
286 
287  // Threat Region configuration
288 
289  /**
290  * Enables or disables rendering of the Threat Intervisibility regions.
291  * \param enabled true if threat regions should be rendered, false if they should not
292  */
293  void SetThreatLayerEnabled( bool enabled );
294 
295  /**
296  * Sets the elevation band priority for the threat regions. This value indicates which
297  * terrain elevation bands that the threat regions should take render priority over. Any
298  * elevation bands with an index equal to or higher than this value are visually
299  * superseded by the presense of a threat region. For example, if this value is 2, then
300  * the first two elevation bands are always displayed, even within threatened regions, but
301  * the threat regions are displayed instead of the third (and subsequent) bands.
302  * \param bandIndex The index of the elevation band which the threat region should
303  * visually override. Must be in the range 0 - 15, inclusive.
304  */
305  void SetThreatLayerBand( unsigned int bandIndex );
306 
307  /**
308  * Enables or disables one of the threat sources for the threat region rendering. A
309  * disabled threat never generates any threat region.
310  * \param threatIndex The zero-based index of the threat to enable or disable. Must be in
311  * the range 0 - 15, inclusive.
312  * \param enabled true to enable the threat, false to disable it
313  */
314  void SetThreatLayerThreatEnabled( unsigned int threatIndex, bool enabled );
315 
316  /**
317  * Sets the position of a threat source. The location structure contains the latitude
318  * (degrees), longitude (degrees), and altitude (meters) of the threat.
319  * \param threatIndex The zero-based index of the threat to set the location of. Must be
320  * in the range 0 - 15, inclusive.
321  * \param location The structure containing the threat's new location.
322  */
323  void SetThreatLayerThreatLocation( unsigned int threatIndex, GeoCoord location );
324 
325  /**
326  * Sets the radius of a threat's 'Algorithm' area. Locations outside of this range are not
327  * considered in the line-of-sight calculations.
328  * \param threatIndex The zero-based index of the threat to set the range of. Must be in
329  * the range 0 - 15, inclusive.
330  * \param sightRadius The distance at which this source can threaten, measured in meters.
331  */
332  void SetThreatLayerThreatRadius( unsigned int threatIndex, double sightRadius );
333 
334  /**
335  * Sets the radius of a threat's 'Lethality' area. A circle of this radius is drawn
336  * centered on the threat's location.
337  * \param threatIndex The zero-based index of the threat to set the range of. Must be in
338  * the range 0 - 15, inclusive.
339  * \param lethalityRadius The radius of the lethality circle, measured in meters.
340  */
341  void SetThreatLayerThreatLethalityRadius( unsigned int threatIndex, double lethalityRadius );
342 
343  /**
344  * Sets the radius of a threat's 'Detection' area. A circle of this radius is drawn
345  * centered on the threat's location.
346  * \param threatIndex The zero-based index of the threat to set the range of. Must be in
347  * the range 0 - 15, inclusive.
348  * \param detectionRadius The radius of the detection circle, measured in meters.
349  */
350  void SetThreatLayerThreatDetectionRadius( unsigned int threatIndex, double detectionRadius );
351 
352  /**
353  * Sets a threat's height. This value is added to the threat's altitude to determine it's
354  * elevation for the threat intervisibility calculation.
355  * \param threatIndex The zero-based index of the threat to set the height of. Must be in
356  * the range 0 - 15, inclusive.
357  * \param height The height of the threat, in meters.
358  */
359  void SetThreatLayerThreatHeight( unsigned int threatIndex, double height );
360 
361  /**
362  * Sets the render color of the threat regions.
363  * \param threatColor The color to use when rendering the threat regions
364  */
365  void SetThreatLayerColor( const glsColor& threatColor );
366 
367  /**
368  * Enables or disables rendering of the 'Algorithm' threat ring.
369  * \param enabled true to enable the ring, false to disable it
370  */
371  void SetThreatLayerAlgorithmRingEnabled( bool enabled );
372 
373  /**
374  * Enables or disables rendering of the 'Lethality' threat ring.
375  * \param enabled true to enable the ring, false to disable it
376  */
377  void SetThreatLayerLethalityRingEnabled( bool enabled );
378 
379  /**
380  * Enables or disables rendering of the 'Detection' threat ring.
381  * \param enabled true to enable the ring, false to disable it
382  */
383  void SetThreatLayerDetectionRingEnabled( bool enabled );
384 
385  /**
386  * Enables or disables rendering of dashes on the 'Algorithm' threat ring.
387  * \param enabled true to enable dashes, false to disable them
388  */
389  void SetThreatLayerAlgorithmRingDashesEnabled( bool enabled );
390 
391  /**
392  * Sets the render color of the 'Algorithm' threat ring.
393  * \param ringColor The color to use when rendering the threat ring
394  */
395  void SetThreatLayerAlgorithmRingColor( glsColor& ringColor );
396 
397  /**
398  * Sets the render color of the 'Lethality' threat ring.
399  * \param ringColor The color to use when rendering the threat ring
400  */
401  void SetThreatLayerLethalityRingColor( glsColor& ringColor );
402 
403  /**
404  * Sets the render color of the 'Detection' threat ring.
405  * \param ringColor The color to use when rendering the threat ring
406  */
407  void SetThreatLayerDetectionRingColor( glsColor& ringColor );
408 
409  /**
410  * Sets the thickness of the 'Algorithm' threat ring, in pixels.
411  * \param lineThickness The threat ring line thickness in pixels
412  */
413  void SetThreatLayerAlgorithmRingThickness( unsigned char lineThickness );
414 
415  /**
416  * Sets the thickness of the 'Lethality' threat ring, in pixels.
417  * \param lineThickness The threat ring line thickness in pixels
418  */
419  void SetThreatLayerLethalityRingThickness( unsigned char lineThickness );
420 
421  /**
422  * Sets the thickness of the 'Detection' threat ring, in pixels.
423  * \param lineThickness The threat ring line thickness in pixels
424  */
425  void SetThreatLayerDetectionRingThickness( unsigned char lineThickness );
426 
427  /**
428  * \returns whether the worker threads have finished running
429  * \param rect The region that all cells that should be done with are in
430  */
431  bool HasWorkerThreadFinishedForArea( const GeoRect& rect );
432 
433  void RemoveData( void );
434 
435 private:
436  // A container that holds all of our elevation data
437  DTEDElevationDataStore* _dataStore;
438 
439  // A container that holds and manages the computation parameters
440  DTEDCalcParamsStore* _paramsStore;
441 
442  // A container that holds all of the map cells
443  DTEDMapChartCellManager* _mapCellManager;
444 
445  // Worker thread for loading dted files from disk
446  DTEDFileLoadThread* _fileLoadThread;
447 
448  // A container that holds a group of worker threads for cell computations
449  DTEDWorkerThreadManager* _workerManager;
450 
451  // A container that holds the shaders that this map uses for rendering
452  DTEDShaderManager* _shaderManager;
453 };
454 /// @}
455 } // namespace disti
456 
457 #endif
void SetThreatLayerAlgorithmRingThickness(unsigned char lineThickness)
void SetThreatLayerAlgorithmRingColor(glsColor &ringColor)
void SetThreatLayerLethalityRingThickness(unsigned char lineThickness)
void SetTerrainLayerIntensityRange(unsigned char lowValue, unsigned char highValue)
void SetTerrainLayerElevationRange(short lowValue, short highValue)
virtual bool GetAvailableCoverage(GeoRect *dest) DISTI_METHOD_OVERRIDE
Definition: gls_map_chart_data_source.h:210
void SetThreatLayerThreatLocation(unsigned int threatIndex, GeoCoord location)
Definition: gls_map_util.h:414
void SetThreatLayerThreatHeight(unsigned int threatIndex, double height)
void SetDiffuseTerrainLayerEnabled(bool enabled)
The GlsMapView is a special group that controls the map view parameters. It contains all of the objec...
Definition: gls_map_view.h:86
short GetElevationDataPoint(double latDegs, double lonDegs)
Definition: gls_map_util.h:67
void GetCellList(const GeoRect &coverage, unsigned long layerID, double viewLogicalHeight, double viewGeoHeight, MapChartCellList &viewList) DISTI_METHOD_OVERRIDE
void SetTerrainLayerEnabled(bool enabled)
void SetContourLayerLineThickness(unsigned char lineThickness)
The Color class: Implements a 4 component RGBA color.
void SetThreatLayerColor(const glsColor &threatColor)
void SetThreatLayerAlgorithmRingEnabled(bool enabled)
void SetThreatLayerDetectionRingEnabled(bool enabled)
void SetThreatLayerThreatDetectionRadius(unsigned int threatIndex, double detectionRadius)
void SetTerrainLayerWaterColor(const glsColor &waterColor)
void SetContourLayerEnabled(bool enabled)
bool HasWorkerThreadFinishedForArea(const GeoRect &rect)
Definition: gls_map_dted.h:72
The disti::GlsMapChartDataSource class.
void SetThreatLayerEnabled(bool enabled)
void SetThreatLayerThreatRadius(unsigned int threatIndex, double sightRadius)
void SetThreatLayerLethalityRingEnabled(bool enabled)
void SetContourLayerInterval(unsigned short interval)
void SetBandingLayerBandDistance(unsigned int bandIndex, unsigned short bandDistance)
Definition: gls_color.h:53
void SetContourLayerHighQuality(bool highQuality)
void SetThreatLayerThreatEnabled(unsigned int threatIndex, bool enabled)
The gls_auto_lib.
void SetThreatLayerAlgorithmRingDashesEnabled(bool enabled)
void AddDataFile(const std::string &filename)
void SetThreatLayerBand(unsigned int bandIndex)
void AddAllFiles(const std::string &directory, bool recurse)
void SetDiffuseTerrainLayerLightDirection(float x, float y, float z)
void SetThreatLayerThreatLethalityRadius(unsigned int threatIndex, double lethalityRadius)
void SetContourLayerLineColor(const glsColor &lineColor)
void SetBandingLayerBandColor(unsigned int bandIndex, const glsColor &bandColor)
void SetBandingLayerBandCount(unsigned int numberOfBands)
void SetThreatLayerDetectionRingThickness(unsigned char lineThickness)
Definition: gls_map_chart.h:70
void SetTerrainLayerTransparency(unsigned char alpha)
void SetAircraftHeight(short aircraftHeight)
Definition: bmpimage.h:46
void SetThreatLayerLethalityRingColor(glsColor &ringColor)
void SetDiffuseTerrainLayerTransparency(unsigned char alpha)
void SetBandingLayerEnabled(bool enabled)
virtual bool AreAllCellsLoaded(GlsMapView *view, GlsMapChart *chart) DISTI_METHOD_OVERRIDE
void SetContourLayerDrawPriority(bool drawOnTop)
void SetThreatLayerDetectionRingColor(glsColor &ringColor)
void SetTerrainLayerWaterEnabled(bool enabled)