libosmscout  1.1.1
WaterIndex.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_WATERINDEX_H
2 #define OSMSCOUT_WATERINDEX_H
3 
4 /*
5  This source is part of the libosmscout library
6  Copyright (C) 2010 Tim Teulings
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Lesser General Public
10  License as published by the Free Software Foundation; either
11  version 2.1 of the License, or (at your option) any later version.
12 
13  This library 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 GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with this library; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22 
23 #include <list>
24 #include <memory>
25 #include <mutex>
26 #include <string>
27 #include <vector>
28 
29 #include <osmscout/GroundTile.h>
30 #include <osmscout/OSMScoutTypes.h>
31 
34 
35 namespace osmscout {
36 
41  {
42  public:
43  static const char* const WATER_IDX;
44 
45  private:
46  struct Level
47  {
48  // Transient
49  double cellWidth;
50  double cellHeight;
51  uint32_t cellXCount;
52  uint32_t cellYCount;
53  FileOffset dataOffset;
54 
55  // Persistent
56 
57  bool hasCellData;
58  uint8_t dataOffsetBytes;
59  GroundTile::Type defaultCellData;
60  FileOffset indexDataOffset;
61 
62  uint32_t cellXStart;
63  uint32_t cellXEnd;
64  uint32_t cellYStart;
65  uint32_t cellYEnd;
66  };
67 
68  private:
69  std::string datafilename;
70  mutable FileScanner scanner;
71 
72  uint32_t waterIndexMinMag;
73  uint32_t waterIndexMaxMag;
74  std::vector<Level> levels;
75 
76  mutable std::mutex lookupMutex;
77 
78  private:
79  void GetGroundTileByDefault(const Level& level,
80  uint32_t cx1,
81  uint32_t cx2,
82  uint32_t cy1,
83  uint32_t cy2,
84  std::list<GroundTile>& tiles) const;
85  void GetGroundTileFromData(const Level& level,
86  uint32_t cx1,
87  uint32_t cx2,
88  uint32_t cy1,
89  uint32_t cy2,
90  std::list<GroundTile>& tiles) const;
91 
92  public:
93  WaterIndex() = default;
94  virtual ~WaterIndex();
95 
96  bool Open(const std::string& path, bool memoryMappedData);
97  void Close();
98 
99  bool GetRegions(const GeoBox& boundingBox,
100  const Magnification& magnification,
101  std::list<GroundTile>& tiles) const;
102 
103  void DumpStatistics();
104  };
105 
106  using WaterIndexRef = std::shared_ptr<WaterIndex>;
107 }
108 
109 #endif
Prints details for debugging, if debug flag (performance, data) is set in renderer parameter...
Definition: MapPainter.h:58
Definition: Area.h:38
Definition: WaterIndex.h:40
#define OSMSCOUT_API
Definition: CoreImportExport.h:45
uint64_t FileOffset
Definition: OSMScoutTypes.h:47
static const char *const WATER_IDX
Definition: WaterIndex.h:43
std::shared_ptr< WaterIndex > WaterIndexRef
Definition: WaterIndex.h:106