4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #ifndef XCSOAR_TERRAIN_RASTER_MAP_HPP
25 #define XCSOAR_TERRAIN_RASTER_MAP_HPP
27 #include "RasterProjection.hpp"
28 #include "RasterTileCache.hpp"
29 #include "Geo/GeoPoint.hpp"
30 #include "Util/NonCopyable.hpp"
36 class OperationEnvironment
;
38 class RasterMap
: private NonCopyable
{
40 RasterTileCache raster_tile_cache
;
41 RasterProjection projection
;
44 RasterMap(const TCHAR
*path
, const TCHAR
*world_file
, FileCache
*cache
,
45 OperationEnvironment
&operation
);
48 bool IsDefined() const {
49 return raster_tile_cache
.GetInitialised();
52 const GeoBounds
&GetBounds() const {
53 return raster_tile_cache
.GetBounds();
57 bool IsInside(const GeoPoint
&pt
) const {
58 return GetBounds().IsInside(pt
);
62 GeoPoint
GetMapCenter() const {
63 return GetBounds().GetCenter();
66 void SetViewCenter(const GeoPoint
&location
, fixed radius
);
69 * Determines if SetViewCenter() should be called again to continue
73 bool IsDirty() const {
74 return raster_tile_cache
.IsDirty();
77 const Serial
&GetSerial() const {
78 return raster_tile_cache
.GetSerial();
82 * @see RasterProjection::CoarsePixelDistance()
85 PixelDistance(const GeoPoint
&location
, unsigned pixels
) const {
86 /* factor 256 because the caller should pass a physical pixel
87 number, not interpolated */
88 return projection
.CoarsePixelDistance(location
, pixels
);
92 * Determine the non-interpolated height at the specified location.
95 short GetHeight(const GeoPoint
&location
) const;
98 * Determine the interpolated height at the specified location.
101 short GetInterpolatedHeight(const GeoPoint
&location
) const;
104 * Scan a straight line and fill the buffer with the specified
105 * number of samples along the line.
107 void ScanLine(const GeoPoint
&start
, const GeoPoint
&end
,
108 short *buffer
, unsigned size
, bool interpolate
) const;
111 bool FirstIntersection(const GeoPoint
&origin
, int h_origin
,
112 const GeoPoint
&destination
, int h_destination
,
113 int h_virt
, int h_ceiling
, int h_safety
,
114 GeoPoint
& intx
, int &h
) const;
117 * Find location where aircraft hits the ground
119 * If the search goes outside the terrain area, will return the destination location
121 * @param origin Start (aircraft) location
122 * @param h_origin Height of aircraft (m)
123 * @param h_glide Height to be glided (m)
124 * @param destination Location of aircraft at MSL
126 * @return Location of intersection, or if none, destination
129 GeoPoint
Intersection(const GeoPoint
& origin
,
130 int h_origin
, int h_glide
,
131 const GeoPoint
& destination
) const;