libosmscout  1.1.1
ImportParameter.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_IMPORTPARAMETER_H
2 #define OSMSCOUT_IMPORTPARAMETER_H
3 
4 /*
5  This source is part of the libosmscout library
6  Copyright (C) 2009 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 
26 
27 #include <memory>
28 
29 namespace osmscout {
30 
31 class Preprocessor;
32 class PreprocessorCallback;
33 
35 {
36 public:
37  virtual ~PreprocessorFactory() = default;
38 
39  virtual std::unique_ptr<Preprocessor> GetProcessor(const std::string& filename,
40  PreprocessorCallback& callback) const = 0;
41 };
42 
43 using PreprocessorFactoryRef = std::shared_ptr<PreprocessorFactory>;
44 
52 class OSMSCOUT_IMPORT_API ImportParameter CLASS_FINAL
53 {
54 public:
59  {
60  private:
61  VehicleMask vehicleMask;
62  std::string filenamebase;
63 
64  public:
65  Router(VehicleMask vehicleMask,
66  const std::string& filenamebase);
67 
68  inline VehicleMask GetVehicleMask() const
69  {
70  return vehicleMask;
71  }
72 
73  inline std::string GetFilenamebase() const
74  {
75  return filenamebase;
76  }
77 
78  inline std::string GetDataFilename() const
79  {
80  return filenamebase+".dat";
81  }
82 
83  inline std::string GetVariantFilename() const
84  {
85  return filenamebase+"2.dat";
86  }
87 
88  inline std::string GetIndexFilename() const
89  {
90  return filenamebase+".idx";
91  }
92  };
93 
94  using RouterRef = std::shared_ptr<Router>;
95 
96  enum class AssumeLandStrategy
97  {
98  disable = 0, // disable land detection by database objects
99  enable = 1, // enable land detection
100  automatic = 2, // disable land detection when data polygon is known
101  };
102 
103 private:
104  std::list<std::string> mapfiles; //<! Name of the files containing map data (either *.osm or *.osm.pbf)
105  std::string typefile; //<! Name and path ff type definition file (map.ost.xml)
106  std::string destinationDirectory; //<! Name of the destination directory
107 
108  ImportErrorReporterRef errorReporter; //<! Class for reporting certain import errors to
109 
110  size_t startStep; //<! Starting step for import
111  size_t endStep; //<! End step for import
112  std::string boundingPolygonFile; //<! Polygon file containing the bounding polygon of the current import
113  bool eco; //<! Eco modus, deletes temporary files ASAP
114  std::list<Router> router; //<! Definition of router
115 
116  bool strictAreas; //<! Assure that areas conform to "simple" definition
117 
118  bool sortObjects; //<! Sort all objects
119  size_t sortBlockSize; //<! Number of entries loaded in one sort iteration
120  size_t sortTileMag; //<! Zoom level for individual sorting cells
121 
122  size_t processingQueueSize;
123 
124  size_t numericIndexPageSize; //<! Size of an numeric index page in bytes
125 
126  size_t rawCoordBlockSize; //<! Number of raw coords loaded during import in one go
127 
128  bool rawNodeDataMemoryMaped; //<! Use memory mapping for raw node data file access
129 
130  bool rawWayIndexMemoryMaped; //<! Use memory mapping for raw way index file access
131  bool rawWayDataMemoryMaped; //<! Use memory mapping for raw way data file access
132  size_t rawWayIndexCacheSize; //<! Size of the raw way index cache
133  size_t rawWayBlockSize; //<! Number of ways loaded during import until nodes get resolved
134 
135  bool coordDataMemoryMaped; //<! Use memory mapping for coord data file access
136  size_t coordIndexCacheSize; //<! Size of the coord index cache
137  size_t coordBlockSize; //<! Maximum number of node ids we resolve in one go
138 
139  size_t relMaxWays; //<! Maximum number of ways allowed to resolve a relation
140  size_t relMaxCoords; //<! Maximum number of coords allowed to resolve a relation
141 
142  bool areaDataMemoryMaped; //<! Use memory mapping for area data file access
143  size_t areaDataCacheSize; //<! Size of the area data cache
144 
145  bool wayDataMemoryMaped; //<! Use memory mapping for way data file access
146  size_t wayDataCacheSize; //<! Size of the way data cache
147 
148  size_t areaAreaIndexMaxMag; //<! Maximum depth of the index generated
149 
150  MagnificationLevel areaNodeGridMag; //<! Magnification level for the index grid
151  uint16_t areaNodeSimpleListLimit; //<! If a type has less entries, we just store them plain
152  uint16_t areaNodeTileListLimit; //<! If a type has less entries in a tile, we store it as list
153  uint16_t areaNodeTileListCoordLimit;//<! If a type has less entries we store the coord in tile lists
154  MagnificationLevel areaNodeBitmapMaxMag; //<! Maximum Magnification level for bitmap index
155  uint16_t areaNodeBitmapLimit; //<! All cells must have less entries for a given zoom level
156 
157  MagnificationLevel areaWayMinMag; //<! Minimum magnification of index for individual type
158  MagnificationLevel areaWayIndexMaxLevel; //<! Maximum zoom level for area way index bitmap
159 
160  MagnificationLevel areaRouteMinMag; //<! Minimum magnification of index for individual type
161  MagnificationLevel areaRouteIndexMaxLevel; //<! Maximum zoom level for area route index bitmap
162 
163  uint32_t waterIndexMinMag; //<! Minimum level of the generated water index
164  uint32_t waterIndexMaxMag; //<! Maximum level of the generated water index
165 
166  size_t optimizationMaxWayCount; //<! Maximum number of ways for one iteration
167  MagnificationLevel optimizationMaxMag; //<! Maximum magnification for optimization
168  MagnificationLevel optimizationMinMag; //<! Minimum magnification of index for individual type
169  size_t optimizationCellSizeAverage; //<! Average entries per index cell
170  size_t optimizationCellSizeMax; //<! Maximum number of entries per index cell
171  TransPolygon::OptimizeMethod optimizationWayMethod; //<! what method to use to optimize ways
172 
173  size_t routeNodeBlockSize; //<! Number of route nodes loaded during import until ways get resolved
174  uint32_t routeNodeTileMag; //<! Size of a routing tile
175 
176  AssumeLandStrategy assumeLand; //<! During sea/land detection,we either trust coastlines only or make some
177  //<! assumptions which tiles are sea and which are land.
178  std::vector<std::string> langOrder; //<! languages used when parsing name[:lang] and
179  //<! place_name[:lang] tags
180  std::vector<std::string> altLangOrder; //<! the same as langOrder but for a alt (second) lang
181 
182  size_t maxAdminLevel; //<! Maximum admin level that gets evalutated
183 
184  OSMId firstFreeOSMId; //<! first id available for synthetic objects (parsed polygon files)
185  size_t fillWaterArea; //<! count of tiles around coastlines flooded by water
186 
187  PreprocessorFactoryRef preprocessorFactory; //<! Optional preprocessor factory to inject custom preprocessors
188 
189  public:
190  ImportParameter();
191  virtual ~ImportParameter();
192 
193  const std::list<std::string>& GetMapfiles() const;
194  std::string GetTypefile() const;
195  std::string GetDestinationDirectory() const;
196  std::string GetBoundingPolygonFile() const;
197 
198  ImportErrorReporterRef GetErrorReporter() const;
199 
200  size_t GetStartStep() const;
201  size_t GetEndStep() const;
202  bool IsEco() const;
203 
204  const std::list<Router>& GetRouter() const;
205 
206  bool GetStrictAreas() const;
207 
208  bool GetSortObjects() const;
209  size_t GetSortBlockSize() const;
210  size_t GetSortTileMag() const;
211 
212  size_t GetProcessingQueueSize() const;
213 
214  size_t GetNumericIndexPageSize() const;
215 
216  size_t GetRawCoordBlockSize() const;
217 
218  bool GetRawNodeDataMemoryMaped() const;
219 
220  bool GetRawWayIndexMemoryMaped() const;
221  bool GetRawWayDataMemoryMaped() const;
222  size_t GetRawWayIndexCacheSize() const;
223  size_t GetRawWayBlockSize() const;
224 
225  bool GetCoordDataMemoryMaped() const;
226  size_t GetCoordIndexCacheSize() const;
227 
228  size_t GetCoordBlockSize() const;
229 
230  size_t GetRelMaxWays() const;
231  size_t GetRelMaxCoords() const;
232 
233  bool GetAreaDataMemoryMaped() const;
234  size_t GetAreaDataCacheSize() const;
235 
236  bool GetWayDataMemoryMaped() const;
237  size_t GetWayDataCacheSize() const;
238 
239  MagnificationLevel GetAreaNodeGridMag() const;
240  uint16_t GetAreaNodeSimpleListLimit() const;
241  uint16_t GetAreaNodeTileListLimit() const;
242  uint16_t GetAreaNodeTileListCoordLimit() const;
243  MagnificationLevel GetAreaNodeBitmapMaxMag() const;
244  uint16_t GetAreaNodeBitmapLimit() const;
245 
246  MagnificationLevel GetAreaWayMinMag() const;
247  MagnificationLevel GetAreaWayIndexMaxLevel() const;
248 
249  MagnificationLevel GetAreaRouteMinMag() const;
250  MagnificationLevel GetAreaRouteIndexMaxLevel() const;
251 
252  size_t GetAreaAreaIndexMaxMag() const;
253 
254  uint32_t GetWaterIndexMinMag() const;
255  uint32_t GetWaterIndexMaxMag() const;
256 
257  size_t GetOptimizationMaxWayCount() const;
258  MagnificationLevel GetOptimizationMaxMag() const;
259  MagnificationLevel GetOptimizationMinMag() const;
260  size_t GetOptimizationCellSizeAverage() const;
261  size_t GetOptimizationCellSizeMax() const;
262  TransPolygon::OptimizeMethod GetOptimizationWayMethod() const;
263 
264  size_t GetRouteNodeBlockSize() const;
265  uint32_t GetRouteNodeTileMag() const;
266 
267  AssumeLandStrategy GetAssumeLand() const;
268 
269  OSMId GetFirstFreeOSMId() const;
270 
271  const std::vector<std::string>& GetLangOrder () const;
272  const std::vector<std::string>& GetAltLangOrder () const;
273 
274  size_t GetMaxAdminLevel() const;
275 
276  void SetMapfiles(const std::list<std::string>& mapfile);
277  void SetTypefile(const std::string& typefile);
278  void SetDestinationDirectory(const std::string& destinationDirectory);
279  void SetBoundingPolygonFile(const std::string& boundingPolygonFile);
280 
281  void SetErrorReporter(const ImportErrorReporterRef& errorReporter);
282 
283  void SetStartStep(size_t startStep);
284  void SetSteps(size_t startStep, size_t endStep);
285  void SetEco(bool eco);
286 
287  void ClearRouter();
288  void AddRouter(const Router& router);
289 
290  void SetStrictAreas(bool strictAreas);
291 
292  void SetSortObjects(bool sortObjects);
293  void SetSortBlockSize(size_t sortBlockSize);
294  void SetSortTileMag(size_t sortTileMag);
295 
296  void SetProcessingQueueSize(size_t processingQueueSize);
297 
298  void SetNumericIndexPageSize(size_t numericIndexPageSize);
299 
300  void SetRawCoordBlockSize(size_t blockSize);
301 
302  void SetRawNodeDataMemoryMaped(bool memoryMaped);
303 
304  void SetRawWayIndexMemoryMaped(bool memoryMaped);
305  void SetRawWayDataMemoryMaped(bool memoryMaped);
306  void SetRawWayIndexCacheSize(size_t wayIndexCacheSize);
307  void SetRawWayBlockSize(size_t blockSize);
308 
309  void SetCoordDataMemoryMaped(bool memoryMaped);
310  void SetCoordIndexCacheSize(size_t coordIndexCacheSize);
311 
312  void SetCoordBlockSize(size_t coordBlockSize);
313 
314  void SetRelMaxWays(size_t relMaxWays);
315  void SetRelMaxCoords(size_t relMaxCoords);
316 
317  void SetAreaDataMemoryMaped(bool memoryMaped);
318  void SetAreaDataCacheSize(size_t areaDataCacheSize);
319 
320  void SetWayDataMemoryMaped(bool memoryMaped);
321  void SetWayDataCacheSize(size_t wayDataCacheSize);
322 
323  void SetAreaAreaIndexMaxMag(size_t areaAreaIndexMaxMag);
324 
325  void SetAreaNodeGridMag(MagnificationLevel areaNodeGridMag);
326  void SetAreaNodeSimpleListLimit(uint16_t areaNodeSimpleListLimit);
327  void SetAreaNodeTileListLimit(uint16_t areaNodeTileListLimit);
328  void SetAreaNodeTileListCoordLimit(uint16_t areaNodeTileListCoordLimit);
329  void SetAreaNodeBitmapMaxMag(const MagnificationLevel& areaNodeBitmapMaxMag);
330  void SetAreaNodeBitmapLimit(uint16_t areaNodeBitmapLimit);
331 
332  void SetAreaWayMinMag(MagnificationLevel areaWayMinMag);
333  void SetAreaWayIndexMaxMag(MagnificationLevel areaWayIndexMaxLevel);
334 
335  void SetAreaRouteMinMag(MagnificationLevel areaRouteMinMag);
336  void SetAreaRouteIndexMaxMag(MagnificationLevel areaRouteIndexMaxLevel);
337 
338  void SetWaterIndexMinMag(uint32_t waterIndexMinMag);
339  void SetWaterIndexMaxMag(uint32_t waterIndexMaxMag);
340 
341  void SetOptimizationMaxWayCount(size_t optimizationMaxWayCount);
342  void SetOptimizationMaxMag(MagnificationLevel optimizationMaxMag);
343  void SetOptimizationMinMag(MagnificationLevel optimizationMinMag);
344  void SetOptimizationCellSizeAverage(size_t optimizationCellSizeAverage);
345  void SetOptimizationCellSizeMax(size_t optimizationCellSizeMax);
346  void SetOptimizationWayMethod(TransPolygon::OptimizeMethod optimizationWayMethod);
347 
348  void SetRouteNodeBlockSize(size_t blockSize);
349  void SetRouteNodeTileMag(uint32_t routeNodeTileMag);
350 
351  void SetAssumeLand(AssumeLandStrategy assumeLand);
352 
353  void SetLangOrder(const std::vector<std::string>& langOrder);
354  void SetAltLangOrder(const std::vector<std::string>& altLangOrder);
355 
356  void SetMaxAdminLevel(size_t maxAdminLevel);
357 
358  void SetFirstFreeOSMId(OSMId id);
359 
360  void SetFillWaterArea(size_t fillWaterArea);
361  size_t GetFillWaterArea() const;
362 
363  void SetPreprocessorFactory(const PreprocessorFactoryRef& factory);
364 
365  std::unique_ptr<Preprocessor> GetPreprocessor(const std::string& filename,
366  PreprocessorCallback& callback) const;
367 
368  void SetAreaWayIndexMaxLevel(const MagnificationLevel& areaWayIndexMaxLevel);
369 
370  static size_t GetDefaultStartStep();
371  static size_t GetDefaultEndStep();
372 };
373 
374 }
375 
376 #endif //OSMSCOUT_IMPORTPARAMETER_H
std::string GetFilenamebase() const
Definition: ImportParameter.h:73
std::shared_ptr< ImportErrorReporter > ImportErrorReporterRef
Definition: ImportErrorReporter.h:137
AssumeLandStrategy
Definition: ImportParameter.h:96
int64_t OSMId
Definition: OSMScoutTypes.h:34
Definition: Area.h:86
std::string GetVariantFilename() const
Definition: ImportParameter.h:83
#define OSMSCOUT_IMPORT_API
Definition: ImportImportExport.h:45
VehicleMask GetVehicleMask() const
Definition: ImportParameter.h:68
Definition: Area.h:38
std::shared_ptr< Router > RouterRef
Definition: ImportParameter.h:94
Definition: ImportParameter.h:34
Definition: Preprocessor.h:35
std::string GetIndexFilename() const
Definition: ImportParameter.h:88
Definition: Router.h:46
std::string GetDataFilename() const
Definition: ImportParameter.h:78
uint8_t VehicleMask
Definition: OSMScoutTypes.h:62
std::shared_ptr< PreprocessorFactory > PreprocessorFactoryRef
Definition: ImportParameter.h:43