summaryrefslogtreecommitdiff
path: root/src/mbgl/style/source.hpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-04-26 16:39:56 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-06-02 14:51:39 -0700
commitc902f9098b331302aaa1baac77d1575db624a132 (patch)
tree211901cd04454aedbac40c469198438e46d7038c /src/mbgl/style/source.hpp
parent18149cbcc27a926f280b08d8d0e09104b2147688 (diff)
downloadqtlocation-mapboxgl-c902f9098b331302aaa1baac77d1575db624a132.tar.gz
[core] Rationalize naming for style-related code
Diffstat (limited to 'src/mbgl/style/source.hpp')
-rw-r--r--src/mbgl/style/source.hpp113
1 files changed, 113 insertions, 0 deletions
diff --git a/src/mbgl/style/source.hpp b/src/mbgl/style/source.hpp
new file mode 100644
index 0000000000..cadc45c25c
--- /dev/null
+++ b/src/mbgl/style/source.hpp
@@ -0,0 +1,113 @@
+#pragma once
+
+#include <mbgl/tile/tile_id.hpp>
+#include <mbgl/tile/tile_data.hpp>
+#include <mbgl/tile/tile_cache.hpp>
+#include <mbgl/style/types.hpp>
+#include <mbgl/renderer/renderable.hpp>
+
+#include <mbgl/util/mat4.hpp>
+#include <mbgl/util/rapidjson.hpp>
+#include <mbgl/util/feature.hpp>
+#include <mbgl/util/tileset.hpp>
+
+#include <forward_list>
+#include <vector>
+#include <map>
+
+namespace mapbox {
+namespace geojsonvt {
+class GeoJSONVT;
+} // namespace geojsonvt
+} // namespace mapbox
+
+namespace mbgl {
+
+class Painter;
+class FileSource;
+class AsyncRequest;
+class TransformState;
+class Tile;
+struct ClipID;
+
+namespace style {
+
+class Style;
+class UpdateParameters;
+class QueryParameters;
+class SourceObserver;
+
+class Source : private util::noncopyable {
+public:
+ Source(SourceType,
+ const std::string& id,
+ const std::string& url,
+ uint16_t tileSize,
+ std::unique_ptr<Tileset>&&,
+ std::unique_ptr<mapbox::geojsonvt::GeoJSONVT>&&);
+ ~Source();
+
+ bool loaded = false;
+ void load(FileSource&);
+ bool isLoading() const;
+ bool isLoaded() const;
+
+ const Tileset* getTileset() const { return tileset.get(); }
+
+ // Request or parse all the tiles relevant for the "TransformState". This method
+ // will return true if all the tiles were scheduled for updating of false if
+ // they were not. shouldReparsePartialTiles must be set to "true" if there is
+ // new data available that a tile in the "partial" state might be interested at.
+ bool update(const UpdateParameters&);
+
+ template <typename ClipIDGenerator>
+ void updateClipIDs(ClipIDGenerator& generator) {
+ generator.update(tiles);
+ }
+
+ void updateMatrices(const mat4 &projMatrix, const TransformState &transform);
+ void finishRender(Painter &painter);
+
+ const std::map<UnwrappedTileID, Tile>& getTiles() const;
+
+ TileData* getTileData(const OverscaledTileID&) const;
+
+ std::unordered_map<std::string, std::vector<Feature>>
+ queryRenderedFeatures(const QueryParameters&) const;
+
+ void setCacheSize(size_t);
+ void onLowMemory();
+
+ void setObserver(SourceObserver* observer);
+ void dumpDebugLogs() const;
+
+ const SourceType type;
+ const std::string id;
+ const std::string url;
+ uint16_t tileSize = util::tileSize;
+ bool enabled = false;
+
+private:
+ void tileLoadingCallback(const OverscaledTileID&, std::exception_ptr, bool isNewTile);
+
+ std::unique_ptr<TileData> createTile(const OverscaledTileID&, const UpdateParameters&);
+
+private:
+ std::unique_ptr<const Tileset> tileset;
+
+ std::unique_ptr<mapbox::geojsonvt::GeoJSONVT> geojsonvt;
+
+ // Stores the time when this source was most recently updated.
+ TimePoint updated = TimePoint::min();
+
+ std::map<UnwrappedTileID, Tile> tiles;
+ std::map<OverscaledTileID, std::unique_ptr<TileData>> tileDataMap;
+ TileCache cache;
+
+ std::unique_ptr<AsyncRequest> req;
+
+ SourceObserver* observer = nullptr;
+};
+
+} // namespace style
+} // namespace mbgl