diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2017-01-16 15:08:17 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2017-01-16 15:08:17 -0800 |
commit | cf166717b8e616a3599038ffff440b50251ed7b8 (patch) | |
tree | 74d06c35bdf0d6f970c63c988baef26650515afb /src | |
parent | bd71eb8681529ab70ff892b12128f8b7a5faa4c7 (diff) | |
parent | 7ef2843e6a62116667be6a2c12de085951fdd5ea (diff) | |
download | qtlocation-mapboxgl-cf166717b8e616a3599038ffff440b50251ed7b8.tar.gz |
Merge branch '1ec5-release-ios-v3.4.0-beta.7'
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/style/sources/geojson_source.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/style/sources/geojson_source_impl.cpp | 21 | ||||
-rw-r--r-- | src/mbgl/style/sources/geojson_source_impl.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/style/sources/raster_source.cpp | 12 | ||||
-rw-r--r-- | src/mbgl/style/sources/vector_source.cpp | 12 |
5 files changed, 35 insertions, 14 deletions
diff --git a/src/mbgl/style/sources/geojson_source.cpp b/src/mbgl/style/sources/geojson_source.cpp index 7480438132..62726cd127 100644 --- a/src/mbgl/style/sources/geojson_source.cpp +++ b/src/mbgl/style/sources/geojson_source.cpp @@ -18,7 +18,7 @@ void GeoJSONSource::setGeoJSON(const mapbox::geojson::geojson& geoJSON) { impl->setGeoJSON(geoJSON); } -optional<std::string> GeoJSONSource::getURL() { +optional<std::string> GeoJSONSource::getURL() const { return impl->getURL(); } diff --git a/src/mbgl/style/sources/geojson_source_impl.cpp b/src/mbgl/style/sources/geojson_source_impl.cpp index 7f41e0e321..3f3bc879f7 100644 --- a/src/mbgl/style/sources/geojson_source_impl.cpp +++ b/src/mbgl/style/sources/geojson_source_impl.cpp @@ -47,7 +47,7 @@ void GeoJSONSource::Impl::setURL(std::string url_) { } } -optional<std::string> GeoJSONSource::Impl::getURL() { +optional<std::string> GeoJSONSource::Impl::getURL() const { return url; } @@ -63,15 +63,9 @@ void GeoJSONSource::Impl::_setGeoJSON(const GeoJSON& geoJSON) { cache.clear(); - if (!options.cluster) { - mapbox::geojsonvt::Options vtOptions; - vtOptions.maxZoom = options.maxzoom; - vtOptions.extent = util::EXTENT; - vtOptions.buffer = std::round(scale * options.buffer); - vtOptions.tolerance = scale * options.tolerance; - geoJSONOrSupercluster = std::make_unique<mapbox::geojsonvt::GeoJSONVT>(geoJSON, vtOptions); - - } else { + if (options.cluster + && geoJSON.is<mapbox::geometry::feature_collection<double>>() + && !geoJSON.get<mapbox::geometry::feature_collection<double>>().empty()) { mapbox::supercluster::Options clusterOptions; clusterOptions.maxZoom = options.clusterMaxZoom; clusterOptions.extent = util::EXTENT; @@ -80,6 +74,13 @@ void GeoJSONSource::Impl::_setGeoJSON(const GeoJSON& geoJSON) { const auto& features = geoJSON.get<mapbox::geometry::feature_collection<double>>(); geoJSONOrSupercluster = std::make_unique<mapbox::supercluster::Supercluster>(features, clusterOptions); + } else { + mapbox::geojsonvt::Options vtOptions; + vtOptions.maxZoom = options.maxzoom; + vtOptions.extent = util::EXTENT; + vtOptions.buffer = std::round(scale * options.buffer); + vtOptions.tolerance = scale * options.tolerance; + geoJSONOrSupercluster = std::make_unique<mapbox::geojsonvt::GeoJSONVT>(geoJSON, vtOptions); } for (auto const &item : tiles) { diff --git a/src/mbgl/style/sources/geojson_source_impl.hpp b/src/mbgl/style/sources/geojson_source_impl.hpp index 13994d9078..eec7cf0605 100644 --- a/src/mbgl/style/sources/geojson_source_impl.hpp +++ b/src/mbgl/style/sources/geojson_source_impl.hpp @@ -17,7 +17,7 @@ public: ~Impl() final; void setURL(std::string); - optional<std::string> getURL(); + optional<std::string> getURL() const; void setGeoJSON(const GeoJSON&); void setTileData(GeoJSONTile&, const OverscaledTileID& tileID); diff --git a/src/mbgl/style/sources/raster_source.cpp b/src/mbgl/style/sources/raster_source.cpp index 3c65476df0..94fdbcef12 100644 --- a/src/mbgl/style/sources/raster_source.cpp +++ b/src/mbgl/style/sources/raster_source.cpp @@ -5,7 +5,17 @@ namespace mbgl { namespace style { RasterSource::RasterSource(std::string id, variant<std::string, Tileset> urlOrTileset, uint16_t tileSize) - : Source(SourceType::Raster, std::make_unique<RasterSource::Impl>(std::move(id), *this, std::move(urlOrTileset), tileSize)) { + : Source(SourceType::Raster, std::make_unique<RasterSource::Impl>(std::move(id), *this, std::move(urlOrTileset), tileSize)), + impl(static_cast<Impl*>(baseImpl.get())) { +} + +optional<std::string> RasterSource::getURL() const { + auto urlOrTileset = impl->getURLOrTileset(); + if (urlOrTileset.is<std::string>()) { + return urlOrTileset.get<std::string>(); + } else { + return {}; + } } } // namespace style diff --git a/src/mbgl/style/sources/vector_source.cpp b/src/mbgl/style/sources/vector_source.cpp index f2a6b166a9..4bcd3b8985 100644 --- a/src/mbgl/style/sources/vector_source.cpp +++ b/src/mbgl/style/sources/vector_source.cpp @@ -5,7 +5,17 @@ namespace mbgl { namespace style { VectorSource::VectorSource(std::string id, variant<std::string, Tileset> urlOrTileset) - : Source(SourceType::Vector, std::make_unique<VectorSource::Impl>(std::move(id), *this, std::move(urlOrTileset))) { + : Source(SourceType::Vector, std::make_unique<VectorSource::Impl>(std::move(id), *this, std::move(urlOrTileset))), + impl(static_cast<Impl*>(baseImpl.get())) { +} + +optional<std::string> VectorSource::getURL() const { + auto urlOrTileset = impl->getURLOrTileset(); + if (urlOrTileset.is<std::string>()) { + return urlOrTileset.get<std::string>(); + } else { + return {}; + } } } // namespace style |