1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
#ifndef LLMR_MAP_VECTOR_TILE
#define LLMR_MAP_VECTOR_TILE
#include <llmr/util/pbf.hpp>
#include <llmr/util/vec.hpp>
#include <llmr/style/value.hpp>
#include <llmr/text/glyph.hpp>
#include <llmr/style/filter_expression.hpp>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <limits>
namespace llmr {
class BucketDescription;
class VectorTileLayer;
struct pbf;
enum class FeatureType {
Unknown = 0,
Point = 1,
LineString = 2,
Polygon = 3
};
std::ostream& operator<<(std::ostream&, const FeatureType& type);
class VectorTileFeature {
public:
VectorTileFeature(pbf feature, const VectorTileLayer& layer);
uint64_t id = 0;
FeatureType type = FeatureType::Unknown;
std::map<std::string, Value> properties;
pbf geometry;
};
std::ostream& operator<<(std::ostream&, const VectorTileFeature& feature);
class VectorTileTagExtractor {
public:
VectorTileTagExtractor(const VectorTileLayer &layer);
void setTags(const pbf &pbf);
std::vector<Value> getValues(const std::string &key) const;
void setType(FilterExpression::GeometryType type);
FilterExpression::GeometryType getType() const;
private:
const VectorTileLayer &layer_;
pbf tags_;
FilterExpression::GeometryType type_ = FilterExpression::GeometryType::Any;
};
/*
* Allows iterating over the features of a VectorTileLayer using a
* BucketDescription as filter. Only features matching the descriptions will
* be returned (as pbf).
*/
class FilteredVectorTileLayer {
public:
class iterator {
public:
iterator(const FilteredVectorTileLayer& filter, const pbf& data);
void operator++();
bool operator!=(const iterator& other) const;
const pbf& operator*() const;
private:
const FilteredVectorTileLayer& parent;
bool valid = false;
pbf feature;
pbf data;
};
public:
FilteredVectorTileLayer(const VectorTileLayer& layer, const FilterExpression &filterExpression);
iterator begin() const;
iterator end() const;
private:
const VectorTileLayer& layer;
const FilterExpression& filterExpression;
};
std::ostream& operator<<(std::ostream&, const GlyphPlacement& placement);
class VectorTileLayer {
public:
VectorTileLayer(pbf data);
const pbf data;
std::string name;
uint32_t extent = 4096;
std::vector<std::string> keys;
std::unordered_map<std::string, uint32_t> key_index;
std::vector<Value> values;
std::map<std::string, std::map<Value, Shaping>> shaping;
};
class VectorTile {
public:
VectorTile();
VectorTile(pbf data);
VectorTile& operator=(VectorTile&& other);
std::map<std::string, const VectorTileLayer> layers;
};
}
#endif
|