libosmscout  1.1.1
ImportErrorReporter.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_IMPORT_IMPORTERRORREPORTER_H
2 #define OSMSCOUT_IMPORT_IMPORTERRORREPORTER_H
3 
4 /*
5  This source is part of the libosmscout library
6  Copyright (C) 2016 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 <mutex>
24 #include <string>
25 
27 
28 #include <osmscout/ObjectRef.h>
29 #include <osmscout/TypeConfig.h>
30 
32 #include <osmscout/util/Progress.h>
34 
36 
37 namespace osmscout {
38 
43  class OSMSCOUT_IMPORT_API ImportErrorReporter CLASS_FINAL: public TagErrorReporter
44  {
45  public:
46  static const char* const FILENAME_INDEX_HTML;
47  static const char* const FILENAME_TAG_HTML;
48  static const char* const FILENAME_WAY_HTML;
49  static const char* const FILENAME_RELATION_HTML;
50  static const char* const FILENAME_LOCATION_HTML;
51 
52 
53  private:
54  enum Report {
55  reportLocation
56  };
57 
58  private:
59  struct ReportError
60  {
61  Report report;
62  ObjectFileRef ref;
63  std::string error;
64 
65  inline ReportError(Report report,
66  const ObjectFileRef& ref,
67  const std::string& error)
68  : report(report),
69  ref(ref),
70  error(error)
71  {
72  // no code
73  }
74  };
75 
76  private:
77  Progress& progress;
78 
79  TypeConfigRef typeConfig;
80  TagId nameTagId;
81 
82  std::string destinationDirectory;
83 
84  std::list<ReportError> errors;
85 
86  HTMLWriter tagReport;
87  size_t tagErrorCount;
88 
89  HTMLWriter wayReport;
90  size_t wayErrorCount;
91 
92  HTMLWriter relationReport;
93  size_t relationErrorCount;
94 
95  HTMLWriter locationReport;
96  size_t locationErrorCount;
97 
98  HTMLWriter index;
99 
100  std::mutex mutex;
101 
102  private:
103  std::string GetName(const ObjectOSMRef& object,
104  const TagMap& tags) const;
105 
106  public:
107  ImportErrorReporter(Progress& progress,
108  const TypeConfigRef& typeConfig,
109  const std::string& destinationDirectory);
110 
111  ~ImportErrorReporter() override;
112 
113  void ReportTag(const ObjectOSMRef &object,
114  const TagMap& tags,
115  const std::string& error) override;
116 
117  void ReportWay(OSMId id,
118  const TagMap& tags,
119  const std::string& error);
120 
121  void ReportRelation(OSMId id,
122  const TagMap& tags,
123  const std::string& error);
124  void ReportRelation(OSMId id,
125  const TypeInfoRef& type,
126  const std::string& error);
127 
128  void ReportLocationDebug(const ObjectFileRef& object,
129  const std::string& error);
130 
131  void ReportLocation(const ObjectFileRef& object,
132  const std::string& error);
133 
134  void FinishedImport();
135  };
136 
137  typedef std::shared_ptr<ImportErrorReporter> ImportErrorReporterRef;
138 }
139 
140 #endif
std::shared_ptr< ImportErrorReporter > ImportErrorReporterRef
Definition: ImportErrorReporter.h:137
uint16_t TagId
Definition: Tag.h:39
int64_t OSMId
Definition: OSMScoutTypes.h:34
static const char *const FILENAME_LOCATION_HTML
Definition: ImportErrorReporter.h:50
#define OSMSCOUT_IMPORT_API
Definition: ImportImportExport.h:45
static const char *const FILENAME_INDEX_HTML
Definition: ImportErrorReporter.h:46
static const char *const FILENAME_WAY_HTML
Definition: ImportErrorReporter.h:48
Definition: Area.h:38
#define CLASS_FINAL
Definition: Compiler.h:26
static const char *const FILENAME_TAG_HTML
Definition: ImportErrorReporter.h:47
std::shared_ptr< TypeInfo > TypeInfoRef
Definition: TypeConfig.h:58
std::unordered_map< TagId, std::string > TagMap
Definition: Tag.h:41
std::shared_ptr< TypeConfig > TypeConfigRef
Definition: TypeConfig.h:1227
static const char *const FILENAME_RELATION_HTML
Definition: ImportErrorReporter.h:49