KOSMIndoorMap

o5mparser.h
1/*
2 SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef OSM_O5MPARSER_H
8#define OSM_O5MPARSER_H
9
10#include "kosm_export.h"
11#include "abstractreader.h"
12
13#include <cstddef>
14#include <cstdint>
15#include <vector>
16
17class O5mParserTest;
18
19namespace OSM {
20
21class DataSet;
22class DataSetMergeBuffer;
23
24/** Zero-copy parser of O5M binary files.
25 * @see https://wiki.openstreetmap.org/wiki/O5m
26 */
27class KOSM_EXPORT O5mParser : public AbstractReader
28{
29public:
30 explicit O5mParser(DataSet *dataSet);
31
32private:
33 void readFromData(const uint8_t *data, std::size_t len) override;
34
35 friend class ::O5mParserTest;
36
37 [[nodiscard]] uint64_t readUnsigned(const uint8_t *&it, const uint8_t *endIt) const;
38 [[nodiscard]] int64_t readSigned(const uint8_t *&it, const uint8_t *endIt) const;
39 template <typename T>
40 [[nodiscard]] T readDelta(const uint8_t *&it, const uint8_t *endIt, T &deltaState);
41
42 [[nodiscard]] const char* readString(const uint8_t *&it, const uint8_t *endIt);
43 [[nodiscard]] std::pair<const char*, const char*> readStringPair(const uint8_t *&it, const uint8_t *endIt);
44
45 void skipVersionInformation(const uint8_t *&it, const uint8_t *end);
46 template <typename Elem>
47 void readTagOrBbox(Elem &e, const uint8_t *&it, const uint8_t *endIt);
48
49 void readNode(const uint8_t *begin, const uint8_t *end);
50 void readWay(const uint8_t *begin, const uint8_t *end);
51 void readRelation(const uint8_t *begin, const uint8_t *end);
52
53 // delta coding state
54 void resetDeltaCodingState();
55
56 int64_t m_nodeIdDelta = 0;
57 int32_t m_latDelata = 0; // this can overflow, but that is intentional according to the spec!
58 int32_t m_lonDelta = 0;
59
60 int64_t m_wayIdDelta = 0;
61 int64_t m_wayNodeIdDelta = 0;
62
63 int64_t m_relIdDelta = 0;
64 int64_t m_relNodeMemberIdDelta = 0;
65 int64_t m_relWayMemberIdDelta = 0;
66 int64_t m_relRelMemberIdDelta = 0;
67
68 std::vector<const char*> m_stringLookupTable;
69 uint16_t m_stringLookupPosition = 0;
70};
71
72}
73
74#endif // OSM_O5MPARSER_H
Abstract base class for OSM file format readers.
A set of nodes, ways and relations.
Definition datatypes.h:346
Zero-copy parser of O5M binary files.
Definition o5mparser.h:28
Low-level types and functions to work with raw OSM data as efficiently as possible.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:17:55 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.