libosmscout 1.1.1
Loading...
Searching...
No Matches
PreprocessPBF.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_IMPORT_PREPROCESS_PBF_H
2#define OSMSCOUT_IMPORT_PREPROCESS_PBF_H
3
4/*
5 This source is part of the libosmscout library
6 Copyright (C) 2010 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 <future>
24#include <string>
25#include <unordered_map>
26#include <vector>
27
29
31
33
34#if defined(OSMSCOUT_IMPORT_MESON_BUILD) || defined(OSMSCOUT_IMPORT_CMAKE_BUILD)
35 #include <fileformat.pb.h>
36 #include <osmformat.pb.h>
37#else
38 #include <osmscoutimport/pbf/fileformat.pb.h>
39 #include <osmscoutimport/pbf/osmformat.pb.h>
40#endif
41
43
44namespace osmscout {
45
46 class PreprocessPBF CLASS_FINAL : public Preprocessor
47 {
48 private:
49 char *buffer;
50 google::protobuf::int32 bufferSize;
51 PreprocessorCallback& callback;
52 TagMap tagMap;
53 std::vector<OSMId> nodes;
54 std::vector<RawRelation::Member> members;
55
56 private:
57 bool GetPos(FILE* file,
58 FileOffset& pos) const;
59
60 void AssureBlockSize(google::protobuf::int32 length);
61
62 bool ReadBlockHeader(Progress& progress,
63 FILE* file,
64 OSMPBF::BlobHeader& blockHeader,
65 bool silent);
66
67 bool ReadHeaderBlock(Progress& progress,
68 FILE* file,
69 const OSMPBF::BlobHeader& blockHeader,
70 OSMPBF::HeaderBlock& headerBlock);
71
72 bool ReadPrimitiveBlock(Progress& progress,
73 FILE* file,
74 const OSMPBF::BlobHeader& blockHeader,
75 OSMPBF::PrimitiveBlock& primitiveBlock);
76
77 void ReadNodes(const TypeConfig& typeConfig,
78 const OSMPBF::PrimitiveBlock& block,
79 const OSMPBF::PrimitiveGroup &group,
80 PreprocessorCallback::RawBlockData& data);
81
82 void ReadDenseNodes(const TypeConfig& typeConfig,
83 const OSMPBF::PrimitiveBlock& block,
84 const OSMPBF::PrimitiveGroup &group,
85 PreprocessorCallback::RawBlockData& data);
86
87 void ReadWays(const TypeConfig& typeConfig,
88 const OSMPBF::PrimitiveBlock& block,
89 const OSMPBF::PrimitiveGroup &group,
90 PreprocessorCallback::RawBlockData& data);
91
92 void ReadRelations(const TypeConfig& typeConfig,
93 const OSMPBF::PrimitiveBlock& block,
94 const OSMPBF::PrimitiveGroup &group,
95 PreprocessorCallback::RawBlockData& data);
96
97 void ProcessBlock(const TypeConfigRef& typeConfig,
98 std::unique_ptr<OSMPBF::PrimitiveBlock>&& block);
99
100 public:
102 ~PreprocessPBF() override;
103
104 bool Import(const TypeConfigRef& typeConfig,
105 const ImportParameter& parameter,
106 Progress& progress,
107 const std::string& filename) override;
108 };
109}
110
111#endif
Definition Area.h:88
bool Import(const TypeConfigRef &typeConfig, const ImportParameter &parameter, Progress &progress, const std::string &filename) override
PreprocessPBF(PreprocessorCallback &callback)
~PreprocessPBF() override
Definition Preprocessor.h:36
Definition Preprocessor.h:86
std::shared_ptr< TypeConfig > TypeConfigRef
Definition TypeConfig.h:1396
Definition Area.h:39
std::unordered_map< TagId, std::string > TagMap
Definition Tag.h:41