libosmscout  1.1.1
SRTM.h
Go to the documentation of this file.
1 //
2 // SRTM.h
3 // libosmscout
4 //
5 // Created by Vladimir Vyskocil on 06/01/13.
6 // Copyright (c) 2013 Vladimir Vyskocil. All rights reserved.
7 //
8 
9 #ifndef libosmscout_SRTM_h
10 #define libosmscout_SRTM_h
11 
12 /*
13  This source is part of the libosmscout library
14  Copyright (C) 2009 Tim Teulings
15 
16  This library is free software; you can redistribute it and/or
17  modify it under the terms of the GNU Lesser General Public
18  License as published by the Free Software Foundation; either
19  version 2.1 of the License, or (at your option) any later version.
20 
21  This library is distributed in the hope that it will be useful,
22  but WITHOUT ANY WARRANTY; without even the implied warranty of
23  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24  Lesser General Public License for more details.
25 
26  You should have received a copy of the GNU Lesser General Public
27  License along with this library; if not, write to the Free Software
28  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29  */
30 
31 #include <memory>
32 #include <string>
33 #include <vector>
34 
35 #include <osmscout/GeoCoord.h>
36 #include <osmscout/util/GeoBox.h>
37 
38 #include <osmscout/OSMScoutTypes.h>
39 
41 
42 namespace osmscout {
43 
45  {
46  public:
47  GeoBox boundingBox;
48  size_t rows;
49  size_t columns;
50  std::vector<int32_t> heights;
51 
52  inline int32_t GetHeight(size_t x, size_t y) const
53  {
54  return heights[y*columns+x];
55  }
56  };
57 
58  using SRTMDataRef = std::shared_ptr<SRTMData>;
59 
64  {
65  public:
66  static const int32_t nodata=-32768;
67 
68  private:
69  std::string srtmPath;
70  std::string currentFilename;
71  osmscout::GeoBox fileBoundingBox;
72  size_t rows;
73  size_t columns;
74  size_t patchSize;
75  uint8_t *heights;
76 
77  private:
78  bool AssureCorrectFileLoaded(double latitude,
79  double longitude);
80 
81  std::string CalculateHGTFilename(int patchLat,
82  int patchLon) const;
83 
84  int32_t GetHeight(size_t column, size_t row) const;
85 
86  public:
87  explicit SRTM(const std::string& path);
88 
89  virtual ~SRTM();
90 
91  int32_t GetHeightAtLocation(const GeoCoord& coord);
92  SRTMDataRef GetHeightInBoundingBox(const GeoBox& boundingBox);
93  };
94 
95  using SRTMRef = std::shared_ptr<SRTM>;
96 }
97 
98 #endif
std::shared_ptr< SRTMData > SRTMDataRef
Definition: SRTM.h:58
GeoBox boundingBox
Definition: SRTM.h:47
int32_t GetHeight(size_t x, size_t y) const
Definition: SRTM.h:52
std::vector< int32_t > heights
Definition: SRTM.h:50
Definition: SRTM.h:63
Definition: Area.h:38
#define OSMSCOUT_API
Definition: CoreImportExport.h:45
Definition: SRTM.h:44
size_t columns
Definition: SRTM.h:49
size_t rows
Definition: SRTM.h:48
std::shared_ptr< SRTM > SRTMRef
Definition: SRTM.h:95