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
|
#include <mbgl/renderer/sources/render_geojson_source.hpp>
#include <mbgl/renderer/render_tile.hpp>
#include <mbgl/tile/geojson_tile.hpp>
#include <mbgl/algorithm/generate_clip_ids.hpp>
#include <mbgl/algorithm/generate_clip_ids_impl.hpp>
namespace mbgl {
using namespace style;
RenderGeoJSONSource::RenderGeoJSONSource(const style::GeoJSONSource::Impl& impl_)
: RenderSource(impl_),
impl(impl_) {
tilePyramid.setObserver(this);
}
bool RenderGeoJSONSource::isLoaded() const {
return tilePyramid.isLoaded();
}
void RenderGeoJSONSource::invalidateTiles() {
tilePyramid.invalidateTiles();
}
void RenderGeoJSONSource::startRender(algorithm::ClipIDGenerator& generator, const mat4& projMatrix, const mat4& clipMatrix, const TransformState& transform) {
generator.update(tilePyramid.getRenderTiles());
tilePyramid.startRender(projMatrix, clipMatrix, transform);
}
void RenderGeoJSONSource::finishRender(Painter& painter) {
tilePyramid.finishRender(painter);
}
std::map<UnwrappedTileID, RenderTile>& RenderGeoJSONSource::getRenderTiles() {
return tilePyramid.getRenderTiles();
}
void RenderGeoJSONSource::updateTiles(const UpdateParameters& parameters) {
GeoJSONData* data_ = impl.getData();
if (!data_) {
return;
}
if (data_ != data) {
data = data_;
tilePyramid.cache.clear();
for (auto const& item : tilePyramid.tiles) {
static_cast<GeoJSONTile*>(item.second.get())->updateData(data->getTile(item.first.canonical));
}
}
tilePyramid.updateTiles(parameters,
SourceType::GeoJSON,
util::tileSize,
impl.getZoomRange(),
[&] (const OverscaledTileID& tileID) {
return std::make_unique<GeoJSONTile>(tileID, impl.id, parameters, data->getTile(tileID.canonical));
});
}
void RenderGeoJSONSource::removeTiles() {
tilePyramid.removeTiles();
}
void RenderGeoJSONSource::reloadTiles() {
tilePyramid.reloadTiles();
}
std::unordered_map<std::string, std::vector<Feature>>
RenderGeoJSONSource::queryRenderedFeatures(const ScreenLineString& geometry,
const TransformState& transformState,
const RenderedQueryOptions& options) const {
return tilePyramid.queryRenderedFeatures(geometry, transformState, options);
}
std::vector<Feature> RenderGeoJSONSource::querySourceFeatures(const SourceQueryOptions& options) const {
return tilePyramid.querySourceFeatures(options);
}
void RenderGeoJSONSource::setCacheSize(size_t size) {
tilePyramid.setCacheSize(size);
}
void RenderGeoJSONSource::onLowMemory() {
tilePyramid.onLowMemory();
}
void RenderGeoJSONSource::dumpDebugLogs() const {
tilePyramid.dumpDebugLogs();
}
} // namespace mbgl
|