summaryrefslogtreecommitdiff
path: root/src/mbgl/style/sources
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2016-09-20 20:50:27 +0200
committerGitHub <noreply@github.com>2016-09-20 20:50:27 +0200
commit7df9a21f415aa269e7ae435d1500f4a3c7d607e1 (patch)
tree9e383dbb2a7c92dd3d5e983c68795f04252025f3 /src/mbgl/style/sources
parent3755d48441de190a0e94b347ec3ba8e2d54a7285 (diff)
downloadqtlocation-mapboxgl-7df9a21f415aa269e7ae435d1500f4a3c7d607e1.tar.gz
[core] - mutable geojson sources. make tiles protected for geojson_source_impl (#6347)
Diffstat (limited to 'src/mbgl/style/sources')
-rw-r--r--src/mbgl/style/sources/geojson_source_impl.cpp35
-rw-r--r--src/mbgl/style/sources/geojson_source_impl.hpp2
2 files changed, 23 insertions, 14 deletions
diff --git a/src/mbgl/style/sources/geojson_source_impl.cpp b/src/mbgl/style/sources/geojson_source_impl.cpp
index 032576b47e..5b7ba4fc77 100644
--- a/src/mbgl/style/sources/geojson_source_impl.cpp
+++ b/src/mbgl/style/sources/geojson_source_impl.cpp
@@ -65,6 +65,24 @@ void GeoJSONSource::Impl::setGeoJSON(const GeoJSON& geoJSON) {
geoJSONOrSupercluster =
std::make_unique<mapbox::supercluster::Supercluster>(features, clusterOptions);
}
+
+ for (auto const &item : tiles) {
+ GeoJSONTile* geoJSONTile = static_cast<GeoJSONTile*>(item.second.get());
+ setTileData(*geoJSONTile, geoJSONTile->id);
+ }
+}
+
+void GeoJSONSource::Impl::setTileData(GeoJSONTile& tile, const OverscaledTileID& tileID) {
+ if (geoJSONOrSupercluster.is<GeoJSONVTPointer>()) {
+ tile.updateData(geoJSONOrSupercluster.get<GeoJSONVTPointer>()->getTile(tileID.canonical.z,
+ tileID.canonical.x,
+ tileID.canonical.y).features);
+ } else {
+ assert(geoJSONOrSupercluster.is<SuperclusterPointer>());
+ tile.updateData(geoJSONOrSupercluster.get<SuperclusterPointer>()->getTile(tileID.canonical.z,
+ tileID.canonical.x,
+ tileID.canonical.y));
+ }
}
void GeoJSONSource::Impl::loadDescription(FileSource& fileSource) {
@@ -126,20 +144,9 @@ Range<uint8_t> GeoJSONSource::Impl::getZoomRange() {
std::unique_ptr<Tile> GeoJSONSource::Impl::createTile(const OverscaledTileID& tileID,
const UpdateParameters& parameters) {
assert(loaded);
- if (geoJSONOrSupercluster.is<GeoJSONVTPointer>()) {
- return std::make_unique<GeoJSONTile>(tileID, base.getID(), parameters,
- geoJSONOrSupercluster.get<GeoJSONVTPointer>()->getTile(
- tileID.canonical.z,
- tileID.canonical.x,
- tileID.canonical.y).features);
- } else {
- assert(geoJSONOrSupercluster.is<SuperclusterPointer>());
- return std::make_unique<GeoJSONTile>(tileID, base.getID(), parameters,
- geoJSONOrSupercluster.get<SuperclusterPointer>()->getTile(
- tileID.canonical.z,
- tileID.canonical.x,
- tileID.canonical.y));
- }
+ auto tilePointer = std::make_unique<GeoJSONTile>(tileID, base.getID(), parameters);
+ setTileData(*tilePointer.get(), tileID);
+ return std::move(tilePointer);
}
} // namespace style
diff --git a/src/mbgl/style/sources/geojson_source_impl.hpp b/src/mbgl/style/sources/geojson_source_impl.hpp
index cf079e472c..9572355f2c 100644
--- a/src/mbgl/style/sources/geojson_source_impl.hpp
+++ b/src/mbgl/style/sources/geojson_source_impl.hpp
@@ -3,6 +3,7 @@
#include <mbgl/style/source_impl.hpp>
#include <mbgl/style/sources/geojson_source.hpp>
#include <mbgl/util/variant.hpp>
+#include <mbgl/tile/geojson_tile.hpp>
namespace mbgl {
@@ -19,6 +20,7 @@ public:
optional<std::string> getURL();
void setGeoJSON(const GeoJSON&);
+ void setTileData(GeoJSONTile&, const OverscaledTileID& tileID);
void loadDescription(FileSource&) final;