summaryrefslogtreecommitdiff
path: root/src/mbgl/tile/geometry_tile_data.hpp
blob: 6c7ff2f3d9cb2e704971a7d9cc78972cdf700ecb (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
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
#pragma once

#include <mbgl/tile/tile_data.hpp>
#include <mbgl/tile/tile_worker.hpp>
#include <mbgl/text/placement_config.hpp>
#include <mbgl/util/atomic.hpp>
#include <mbgl/util/feature.hpp>

#include <memory>
#include <unordered_map>

namespace mbgl {

class AsyncRequest;
class GeometryTile;
class GeometryTileSource;
class FeatureIndex;

namespace style {
class Style;
}

class GeometryTileData : public TileData {
public:
    GeometryTileData(const OverscaledTileID&,
                     std::string sourceID,
                     style::Style&,
                     const MapMode);

    ~GeometryTileData();

    void setError(std::exception_ptr err);

    void setData(std::unique_ptr<GeometryTile> tile,
                 optional<Timestamp> modified_,
                 optional<Timestamp> expires_);

    Bucket* getBucket(const style::Layer&) override;

    bool parsePending() override;

    void redoPlacement(PlacementConfig) override;

    void queryRenderedFeatures(
            std::unordered_map<std::string, std::vector<Feature>>& result,
            const GeometryCoordinates& queryGeometry,
            const TransformState&,
            const optional<std::vector<std::string>>& layerIDs) override;

    void cancel() override;

private:
    void redoPlacement();

    style::Style& style;
    Worker& worker;
    TileWorker tileWorker;

    std::unique_ptr<AsyncRequest> workRequest;

    // Contains all the Bucket objects for the tile. Buckets are render
    // objects and they get added by tile parsing operations.
    std::unordered_map<std::string, std::unique_ptr<Bucket>> buckets;

    std::unique_ptr<FeatureIndex> featureIndex;
    std::unique_ptr<const GeometryTile> geometryTile;

    // Stores the placement configuration of the text that is currently placed on the screen.
    PlacementConfig placedConfig;

    // Stores the placement configuration of how the text should be placed. This isn't necessarily
    // the one that is being displayed.
    PlacementConfig targetConfig;

    // Used to signal the worker that it should abandon parsing this tile as soon as possible.
    util::Atomic<bool> obsolete { false };
};

} // namespace mbgl