File indexing completed on 2024-10-27 13:24:19

0001 /*
0002     SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KOSM_OSMPBFPARSER_H
0008 #define KOSM_OSMPBFPARSER_H
0009 
0010 #include "abstractreader.h"
0011 #include "datatypes.h"
0012 
0013 namespace OSMPBF {
0014 class PrimitiveBlock;
0015 class PrimitiveGroup;
0016 }
0017 
0018 namespace OSM {
0019 
0020 /** Parser of .osm.pbf files.
0021  *  @see https://wiki.openstreetmap.org/wiki/PBF_Format
0022  */
0023 class OsmPbfParser : public AbstractReader
0024 {
0025 public:
0026     explicit OsmPbfParser(DataSet *dataSet);
0027 
0028 private:
0029     void readFromData(const uint8_t *data, std::size_t len) override;
0030 
0031     bool parseBlob(const uint8_t *&it, const uint8_t *end);
0032     void parsePrimitiveBlock(const uint8_t *data, std::size_t len);
0033     void parseDenseNodes(const OSMPBF::PrimitiveBlock &block,  const OSMPBF::PrimitiveGroup &group);
0034     void parseWays(const OSMPBF::PrimitiveBlock &block, const OSMPBF::PrimitiveGroup &group);
0035     void parseRelations(const OSMPBF::PrimitiveBlock &block, const OSMPBF::PrimitiveGroup &group);
0036 
0037     QByteArray m_zlibBuffer;
0038 };
0039 
0040 }
0041 
0042 #endif // KOSM_OSMPBFPARSER_H