android/GlueIOIOPort: fix spurious errors after IOIO baud rate change
[xcsoar.git] / src / Terrain / RasterMap.hpp
blob58c2dc07fe09edd72637249043d67b3b66b4d52e
1 /*
2 Copyright_License {
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"
31 #include "Compiler.h"
33 #include <tchar.h>
35 class FileCache;
36 class OperationEnvironment;
38 class RasterMap : private NonCopyable {
39 char *path;
40 RasterTileCache raster_tile_cache;
41 RasterProjection projection;
43 public:
44 RasterMap(const TCHAR *path, const TCHAR *world_file, FileCache *cache,
45 OperationEnvironment &operation);
46 ~RasterMap();
48 bool IsDefined() const {
49 return raster_tile_cache.GetInitialised();
52 const GeoBounds &GetBounds() const {
53 return raster_tile_cache.GetBounds();
56 gcc_pure
57 bool IsInside(const GeoPoint &pt) const {
58 return GetBounds().IsInside(pt);
61 gcc_pure
62 GeoPoint GetMapCenter() const {
63 return GetBounds().GetCenter();
66 void SetViewCenter(const GeoPoint &location, fixed radius);
68 /**
69 * Determines if SetViewCenter() should be called again to continue
70 * loading.
72 gcc_pure
73 bool IsDirty() const {
74 return raster_tile_cache.IsDirty();
77 const Serial &GetSerial() const {
78 return raster_tile_cache.GetSerial();
81 /**
82 * @see RasterProjection::CoarsePixelDistance()
84 gcc_pure fixed
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);
91 /**
92 * Determine the non-interpolated height at the specified location.
94 gcc_pure
95 short GetHeight(const GeoPoint &location) const;
97 /**
98 * Determine the interpolated height at the specified location.
100 gcc_pure
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;
110 gcc_pure
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
118 * @todo margin
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
128 gcc_pure
129 GeoPoint Intersection(const GeoPoint& origin,
130 int h_origin, int h_glide,
131 const GeoPoint& destination) const;
136 #endif