libosmscout  1.1.1
GenMergeAreas.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_IMPORT_GENMERGEAREAS_H
2 #define OSMSCOUT_IMPORT_GENMERGEAREAS_H
3 
4 /*
5  This source is part of the libosmscout library
6  Copyright (C) 2013 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 <set>
25 #include <unordered_map>
26 #include <unordered_set>
27 
28 #include <osmscout/TypeInfoSet.h>
29 
30 #include <osmscout/Area.h>
31 #include <osmscout/Way.h>
32 
33 #include <osmscout/import/ImportFeatures.h>
34 #include <osmscout/import/Import.h>
35 
37 
39 
40 namespace osmscout {
41 
45  struct AreaMergeJob
46  {
48  std::unordered_set<Id> nodeUseSet;
49  size_t areaCount;
50  std::list<AreaRef> areas;
51  };
52 
57  {
59  std::list<AreaRef> merges;
60  std::unordered_set<FileOffset> mergedAway;
61  };
62 
67  class MergeAreasGenerator CLASS_FINAL : public ImportModule
68  {
69  public:
70  static const char* const AREAS2_TMP;
71 
72  private:
95  void GetAreas(const ImportParameter& parameter,
96  Progress& progress,
97  const TypeConfig& typeConfig,
98  const TypeInfoSet& candidateTypes,
99  TypeInfoSet& loadedTypes,
100  FileScanner& scanner,
101  std::vector<AreaMergeJob>& mergeJobs);
102 
103  void WriteMergeResult(Progress& progress,
104  const TypeConfig& typeConfig,
105  FileScanner& scanner,
106  FileWriter& writer,
107  const TypeInfoSet& loadedTypes,
108  const std::vector<AreaMergeResult>& mergeJob,
109  uint32_t& areasWritten);
110 
111  public:
112  void GetDescription(const ImportParameter& parameter,
113  ImportModuleDescription& description) const override;
114 
115  bool Import(const TypeConfigRef& typeConfig,
116  const ImportParameter& parameter,
117  Progress& progress) override;
118  };
119 }
120 
121 #endif
std::unordered_set< Id > nodeUseSet
Definition: GenMergeAreas.h:48
TypeInfoRef type
Definition: GenMergeAreas.h:47
Definition: Area.h:86
Definition: GenMergeAreas.h:45
size_t areaCount
Number of areas of this type.
Definition: GenMergeAreas.h:49
std::unordered_set< FileOffset > mergedAway
List of file offsets of areas, that were merged into another area.
Definition: GenMergeAreas.h:60
Definition: Area.h:38
Definition: GenMergeAreas.h:56
TypeInfoRef type
Definition: GenMergeAreas.h:58
static const char *const AREAS2_TMP
Definition: GenMergeAreas.h:70
std::list< AreaRef > areas
List of areas that are candidates for merging.
Definition: GenMergeAreas.h:50
std::list< AreaRef > merges
List of areas that got merged.
Definition: GenMergeAreas.h:59
Definition: ImportModule.h:100
std::shared_ptr< TypeInfo > TypeInfoRef
Definition: TypeConfig.h:58
Definition: Progress.h:34
std::shared_ptr< TypeConfig > TypeConfigRef
Definition: TypeConfig.h:1227