summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2017-01-16 11:38:35 -0800
committerMinh Nguyễn <mxn@1ec5.org>2017-01-16 11:38:35 -0800
commit7ef2843e6a62116667be6a2c12de085951fdd5ea (patch)
tree40eca249e044e2706efd1193d617e6eb8e59d708 /src
parent76301b252cbc4bc3ae1fc84322bcbcdbd26cae8a (diff)
parent13b97dd0cebffe36b187bdb74923910def6bd87b (diff)
downloadqtlocation-mapboxgl-7ef2843e6a62116667be6a2c12de085951fdd5ea.tar.gz
Merge branch 'release-ios-v3.4.0' into 1ec5-release-ios-v3.4.0-beta.7
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/style/sources/geojson_source.cpp2
-rw-r--r--src/mbgl/style/sources/geojson_source_impl.cpp21
-rw-r--r--src/mbgl/style/sources/geojson_source_impl.hpp2
-rw-r--r--src/mbgl/style/sources/raster_source.cpp12
-rw-r--r--src/mbgl/style/sources/vector_source.cpp12
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