libosmscout  1.1.1
OptimizeWaysLowZoom.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_OPTIMIZEWAYSLOWZOOM_H
2 #define OSMSCOUT_OPTIMIZEWAYSLOWZOOM_H
3 
4 /*
5  This source is part of the libosmscout library
6  Copyright (C) 2011 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 <map>
24 #include <memory>
25 #include <mutex>
26 #include <set>
27 #include <string>
28 
29 #include <osmscout/TypeInfoSet.h>
30 
31 #include <osmscout/Way.h>
32 
35 
36 namespace osmscout {
37 
39  {
40  public:
41  static const char* const FILE_WAYSOPT_DAT;
42 
43  private:
44  struct TypeData
45  {
46  uint32_t optLevel;
47  uint32_t indexLevel;
48 
49  uint32_t cellXStart;
50  uint32_t cellXEnd;
51  uint32_t cellYStart;
52  uint32_t cellYEnd;
53 
54  FileOffset bitmapOffset;
55  uint8_t dataOffsetBytes;
56 
57  uint32_t cellXCount;
58  uint32_t cellYCount;
59 
60  double cellWidth;
61  double cellHeight;
62 
63  double minLon;
64  double maxLon;
65  double minLat;
66  double maxLat;
67  };
68 
69  private:
70  TypeConfigRef typeConfig;
71  std::string datafilename;
72  mutable FileScanner scanner;
73 
74  double magnification;
75  std::map<TypeInfoRef,std::list<TypeData> > wayTypesData;
76 
77  mutable std::mutex lookupMutex;
78 
79  private:
80  void ReadTypeData(FileScanner& scanner,
81  TypeData& data);
82 
83  void GetOffsets(const TypeData& typeData,
84  const GeoBox& boundingBox,
85  std::set<FileOffset>& offsets) const;
86 
87  void LoadData(std::set<FileOffset>& offsets,
88  std::vector<WayRef>& ways) const;
89 
90  public:
92  virtual ~OptimizeWaysLowZoom();
93 
94  bool Open(const TypeConfigRef& typeConfig,
95  const std::string& path,
96  bool memoryMappedData);
97  bool Close();
98 
99  bool HasOptimizations(double magnification) const;
100 
101  void GetTypes(const Magnification& magnification,
102  const TypeInfoSet& wayTypes,
103  TypeInfoSet& availableWayTypes) const;
104  bool GetWays(const GeoBox& boundingBox,
105  const Magnification& magnification,
106  const TypeInfoSet& wayTypes,
107  std::vector<WayRef>& ways,
108  TypeInfoSet& loadedWayTypes) const;
109  };
110 
111  using OptimizeWaysLowZoomRef = std::shared_ptr<OptimizeWaysLowZoom>;
112 }
113 
114 #endif
std::shared_ptr< OptimizeWaysLowZoom > OptimizeWaysLowZoomRef
Definition: OptimizeWaysLowZoom.h:111
Definition: Area.h:38
#define OSMSCOUT_API
Definition: CoreImportExport.h:45
uint64_t FileOffset
Definition: OSMScoutTypes.h:47
static const char *const FILE_WAYSOPT_DAT
Definition: OptimizeWaysLowZoom.h:41
std::shared_ptr< TypeConfig > TypeConfigRef
Definition: TypeConfig.h:1227
Definition: OptimizeWaysLowZoom.h:38