libosmscout  1.1.1
GenOptimizeWaysLowZoom.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_IMPORT_GENOPTIMIZEWAYSLOWZOOM_H
2 #define OSMSCOUT_IMPORT_GENOPTIMIZEWAYSLOWZOOM_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 <osmscout/import/ImportFeatures.h>
24 
25 #include <list>
26 #include <set>
27 #include <unordered_map>
28 #include <vector>
29 
30 #include <osmscout/import/Import.h>
31 
32 #include <osmscout/Area.h>
33 #include <osmscout/Way.h>
34 
37 
39 
40 namespace osmscout {
41 
42  class OptimizeWaysLowZoomGenerator CLASS_FINAL : public ImportModule
43  {
44  private:
45  typedef std::unordered_map<FileOffset,FileOffset> FileOffsetFileOffsetMap;
46 
47  struct TypeData
48  {
49  TypeInfoRef type;
50  MagnificationLevel optLevel;
51  MagnificationLevel indexLevel;
52 
53  uint32_t cellXStart;
54  uint32_t cellXEnd;
55  uint32_t cellYStart;
56  uint32_t cellYEnd;
57 
58  FileOffset bitmapOffset;
59  uint8_t dataOffsetBytes;
60 
61  uint32_t cellXCount;
62  uint32_t cellYCount;
63 
64  size_t indexCells;
65  size_t indexEntries;
66 
67  TypeData();
68 
69  inline bool HasEntries()
70  {
71  return indexCells>0 &&
72  indexEntries>0;
73  }
74  };
75 
76  private:
77  void GetWayTypesToOptimize(const TypeConfig& typeConfig,
78  std::set<TypeInfoRef>& types);
79 
80  bool WriteTypeData(FileWriter& writer,
81  const TypeData& data);
82 
83  bool WriteHeader(FileWriter& writer,
84  const std::list<TypeData>& wayTypesData,
85  MagnificationLevel optimizeMaxMap);
86 
87  bool GetWays(const TypeConfig& typeConfig,
88  const ImportParameter& parameter,
89  Progress& progress,
90  FileScanner& scanner,
91  std::set<TypeInfoRef>& types,
92  std::vector<std::list<WayRef> >& ways);
93 
94  void MergeWays(Progress& progress,
95  const std::list<WayRef>& ways,
96  std::list<WayRef>& newWays);
97 
98  void GetWayIndexLevel(const ImportParameter& parameter,
99  const std::list<WayRef>& ways,
100  TypeData& typeData);
101 
102  void OptimizeWays(Progress& progress,
103  const std::list<WayRef>& ways,
104  std::list<WayRef>& optimizedWays,
105  size_t width,
106  size_t height,
107  double dpi,
108  double pixel,
109  const Magnification& magnification,
110  TransPolygon::OptimizeMethod optimizeWayMethod);
111 
112  void WriteWays(const TypeConfig& typeConfig,
113  FileWriter& writer,
114  const std::list<WayRef>& ways,
115  FileOffsetFileOffsetMap& offsets);
116 
117  bool WriteWayBitmap(Progress& progress,
118  FileWriter& writer,
119  const std::list<WayRef>& ways,
120  const FileOffsetFileOffsetMap& offsets,
121  TypeData& data);
122 
123  bool HandleWays(const ImportParameter& parameter,
124  Progress& progress,
125  const TypeConfig& typeConfig,
126  FileWriter& writer,
127  const std::set<TypeInfoRef>& types,
128  std::list<TypeData>& typesData);
129 
130  public:
131  void GetDescription(const ImportParameter& parameter,
132  ImportModuleDescription& description) const override;
133 
134  bool Import(const TypeConfigRef& typeConfig,
135  const ImportParameter& parameter,
136  Progress& progress) override;
137  };
138 }
139 
140 #endif
Definition: Area.h:38
#define CLASS_FINAL
Definition: Compiler.h:26
std::shared_ptr< TypeInfo > TypeInfoRef
Definition: TypeConfig.h:58
uint64_t FileOffset
Definition: OSMScoutTypes.h:47
std::shared_ptr< TypeConfig > TypeConfigRef
Definition: TypeConfig.h:1227