blob: 78317fdcb1f4b1731236172a2b239cedb137d438 (
plain)
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
|
#pragma once
#include <mbgl/actor/actor_ref.hpp>
#include <mbgl/style/sources/custom_geometry_source.hpp>
#include <mbgl/tile/tile_id.hpp>
#include <mbgl/util/geojson.hpp>
#include <map>
#include <mutex>
namespace mbgl {
class CustomGeometryTile;
namespace style {
class CustomTileLoader {
public:
CustomTileLoader(const CustomTileLoader&) = delete;
CustomTileLoader& operator=(const CustomTileLoader&) = delete;
using OverscaledIDFunctionTuple = std::tuple<uint8_t, int16_t, ActorRef<CustomGeometryTile>>;
CustomTileLoader(const TileFunction& fetchTileFn, const TileFunction& cancelTileFn);
void fetchTile(const OverscaledTileID& tileID, const ActorRef<CustomGeometryTile>& tileRef);
void cancelTile(const OverscaledTileID& tileID);
void removeTile(const OverscaledTileID& tileID);
void setTileData(const CanonicalTileID& tileID, const GeoJSON& data);
void invalidateTile(const CanonicalTileID&);
void invalidateRegion(const LatLngBounds&, Range<uint8_t>);
private:
void invokeTileFetch(const CanonicalTileID& tileID);
void invokeTileCancel(const CanonicalTileID& tileID);
TileFunction fetchTileFunction;
TileFunction cancelTileFunction;
std::unordered_map<CanonicalTileID, std::vector<OverscaledIDFunctionTuple>> tileCallbackMap;
// Keep around a cache of tile data to serve back for wrapped and over-zooomed tiles
std::map<CanonicalTileID, std::unique_ptr<GeoJSON>> dataCache;
std::mutex dataMutex;
};
} // namespace style
} // namespace mbgl
|