summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2016-10-25 14:04:50 +0200
committerIvo van Dongen <ivovandongen@users.noreply.github.com>2016-10-25 16:11:36 +0200
commitb14e83ea403662f3e10b9bce95f9b78e5cacea39 (patch)
treede2cffc29efaf27a675545c9ff583f65b3907a27
parent6277dca8985156e313004464337c02128e13cae7 (diff)
downloadqtlocation-mapboxgl-b14e83ea403662f3e10b9bce95f9b78e5cacea39.tar.gz
[core] geojson source - cancel any pending request when setting geojson explicitly
-rw-r--r--src/mbgl/style/sources/geojson_source_impl.cpp13
-rw-r--r--src/mbgl/style/sources/geojson_source_impl.hpp2
2 files changed, 12 insertions, 3 deletions
diff --git a/src/mbgl/style/sources/geojson_source_impl.cpp b/src/mbgl/style/sources/geojson_source_impl.cpp
index f9dfcfb310..4800b9c4be 100644
--- a/src/mbgl/style/sources/geojson_source_impl.cpp
+++ b/src/mbgl/style/sources/geojson_source_impl.cpp
@@ -51,7 +51,14 @@ optional<std::string> GeoJSONSource::Impl::getURL() {
return url;
}
+
void GeoJSONSource::Impl::setGeoJSON(const GeoJSON& geoJSON) {
+ req.reset();
+ _setGeoJSON(geoJSON);
+}
+
+//Private implementation
+void GeoJSONSource::Impl::_setGeoJSON(const GeoJSON& geoJSON) {
double scale = util::EXTENT / util::tileSize;
cache.clear();
@@ -74,7 +81,7 @@ 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);
@@ -134,9 +141,9 @@ void GeoJSONSource::Impl::loadDescription(FileSource& fileSource) {
geoJSON.error().message.c_str());
// Create an empty GeoJSON VT object to make sure we're not infinitely waiting for
// tiles to load.
- setGeoJSON(GeoJSON{ FeatureCollection{} });
+ _setGeoJSON(GeoJSON{ FeatureCollection{} });
} else {
- setGeoJSON(*geoJSON);
+ _setGeoJSON(*geoJSON);
}
loaded = true;
diff --git a/src/mbgl/style/sources/geojson_source_impl.hpp b/src/mbgl/style/sources/geojson_source_impl.hpp
index 9572355f2c..13994d9078 100644
--- a/src/mbgl/style/sources/geojson_source_impl.hpp
+++ b/src/mbgl/style/sources/geojson_source_impl.hpp
@@ -29,6 +29,8 @@ public:
}
private:
+ void _setGeoJSON(const GeoJSON&);
+
Range<uint8_t> getZoomRange() final;
std::unique_ptr<Tile> createTile(const OverscaledTileID&, const UpdateParameters&) final;