libosmscout  1.1.1
GenOptimizeAreasLowZoom.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_IMPORT_GENOPTIMIZEAREASLOWZOOM_H
2 #define OSMSCOUT_IMPORT_GENOPTIMIZEAREASLOWZOOM_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 <map>
26 #include <unordered_map>
27 
28 #include <osmscout/import/Import.h>
29 
30 #include <osmscout/TypeInfoSet.h>
31 
32 #include <osmscout/Area.h>
33 
36 
38 
39 namespace osmscout {
40 
41  class OptimizeAreasLowZoomGenerator CLASS_FINAL : public ImportModule
42  {
43  private:
44  typedef std::unordered_map<FileOffset,FileOffset> FileOffsetFileOffsetMap;
45 
46  struct TypeData
47  {
48  TypeInfoRef type;
49  MagnificationLevel optLevel;
50  MagnificationLevel indexLevel;
51 
52  uint32_t cellXStart;
53  uint32_t cellXEnd;
54  uint32_t cellYStart;
55  uint32_t cellYEnd;
56 
57  FileOffset bitmapOffset;
58  uint8_t dataOffsetBytes;
59 
60  uint32_t cellXCount;
61  uint32_t cellYCount;
62 
63  size_t indexCells;
64  size_t indexEntries;
65 
66  TypeData();
67  };
68 
69  private:
70  void GetAreaTypesToOptimize(const TypeConfig& typeConfig,
71  TypeInfoSet& types);
72 
73  bool WriteTypeData(FileWriter& writer,
74  const TypeData& data);
75 
76  bool WriteHeader(FileWriter& writer,
77  const std::list<TypeData>& areaTypesData,
78  const MagnificationLevel& optimizeMaxMap);
79 
80  bool GetAreas(const TypeConfig& typeConfig,
81  const ImportParameter& parameter,
82  Progress& progress,
83  FileScanner& scanner,
84  const TypeInfoSet& types,
85  std::vector<std::list<AreaRef> >& areas,
86  TypeInfoSet& loadedTypes);
87 
88  void GetAreaIndexLevel(const ImportParameter& parameter,
89  const std::list<AreaRef>& areas,
90  TypeData& typeData);
91 
92  void WriteAreas(const TypeConfig& typeConfig,
93  FileWriter& writer,
94  const std::list<AreaRef>& areas,
95  FileOffsetFileOffsetMap& offsets);
96 
97  bool WriteAreaBitmap(Progress& progress,
98  FileWriter& writer,
99  const std::list<AreaRef>& areas,
100  const FileOffsetFileOffsetMap& offsets,
101  TypeData& data);
102 
103  bool HandleAreas(const ImportParameter& parameter,
104  Progress& progress,
105  const TypeConfig& typeConfig,
106  FileWriter& writer,
107  const TypeInfoSet& types,
108  std::list<TypeData>& typesData);
109 
110  void OptimizeAreas(Progress& progress,
111  const std::list<AreaRef>& areas,
112  std::list<AreaRef>& optimizedAreas,
113  size_t width,
114  size_t height,
115  double dpi,
116  double pixel,
117  const Magnification& magnification,
118  TransPolygon::OptimizeMethod optimizeAreaMethod);
119 
120  public:
121  void GetDescription(const ImportParameter& parameter,
122  ImportModuleDescription& description) const override;
123 
124  bool Import(const TypeConfigRef& typeConfig,
125  const ImportParameter& parameter,
126  Progress& progress) override;
127  };
128 }
129 
130 #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