diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-01-15 11:16:00 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-01-15 11:48:47 -0800 |
commit | 4328e6fd0d973c0a0bc2800f4c67fdbfcae342c9 (patch) | |
tree | 6dc6ebc30bd0f183321cae4ca60ddbf25d8bbd63 /src | |
parent | a88e58ef3a90225fcfafca1efab996de6a827b72 (diff) | |
download | qtlocation-mapboxgl-4328e6fd0d973c0a0bc2800f4c67fdbfcae342c9.tar.gz |
[core] tileSize is a source property, not a TileJSON property
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/annotation/annotation_manager.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/map/source.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/map/source.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/map/source_info.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/style/style_parser.cpp | 18 |
5 files changed, 21 insertions, 6 deletions
diff --git a/src/mbgl/annotation/annotation_manager.cpp b/src/mbgl/annotation/annotation_manager.cpp index 4884ae446f..4e395e0638 100644 --- a/src/mbgl/annotation/annotation_manager.cpp +++ b/src/mbgl/annotation/annotation_manager.cpp @@ -112,7 +112,7 @@ std::unique_ptr<AnnotationTile> AnnotationManager::getTile(const TileID& tileID) void AnnotationManager::updateStyle(Style& style) { // Create annotation source, point layer, and point bucket if (!style.getSource(SourceID)) { - std::unique_ptr<Source> source = std::make_unique<Source>(SourceType::Annotations, SourceID, "", std::make_unique<SourceInfo>(), nullptr); + std::unique_ptr<Source> source = std::make_unique<Source>(SourceType::Annotations, SourceID, "", util::tileSize, std::make_unique<SourceInfo>(), nullptr); source->enabled = true; style.addSource(std::move(source)); diff --git a/src/mbgl/map/source.cpp b/src/mbgl/map/source.cpp index e34ba0748c..4253a60650 100644 --- a/src/mbgl/map/source.cpp +++ b/src/mbgl/map/source.cpp @@ -43,11 +43,13 @@ namespace mbgl { Source::Source(SourceType type_, const std::string& id_, const std::string& url_, + uint16_t tileSize_, std::unique_ptr<SourceInfo>&& info_, std::unique_ptr<mapbox::geojsonvt::GeoJSONVT>&& geojsonvt_) : type(type_), id(id_), url(url_), + tileSize(tileSize_), info(std::move(info_)), geojsonvt(std::move(geojsonvt_)) { } @@ -306,7 +308,7 @@ TileData::State Source::addTile(const TileID& tileID, const StyleUpdateParameter } double Source::getZoom(const TransformState& state) const { - double offset = std::log(util::tileSize / info->tile_size) / std::log(2); + double offset = std::log(util::tileSize / tileSize) / std::log(2); return state.getZoom() + offset; } diff --git a/src/mbgl/map/source.hpp b/src/mbgl/map/source.hpp index ade2317cc5..9e9b6b66ab 100644 --- a/src/mbgl/map/source.hpp +++ b/src/mbgl/map/source.hpp @@ -42,6 +42,7 @@ public: Source(SourceType, const std::string& id, const std::string& url, + uint16_t tileSize, std::unique_ptr<SourceInfo>&&, std::unique_ptr<mapbox::geojsonvt::GeoJSONVT>&&); ~Source(); @@ -73,6 +74,7 @@ public: const SourceType type; const std::string id; const std::string url; + uint16_t tileSize = util::tileSize; bool enabled = false; private: diff --git a/src/mbgl/map/source_info.hpp b/src/mbgl/map/source_info.hpp index 0f0ee1cad4..01d01b60a9 100644 --- a/src/mbgl/map/source_info.hpp +++ b/src/mbgl/map/source_info.hpp @@ -16,7 +16,6 @@ class TileID; class SourceInfo { public: std::vector<std::string> tiles; - uint16_t tile_size = util::tileSize; uint16_t min_zoom = 0; uint16_t max_zoom = 22; std::string attribution; diff --git a/src/mbgl/style/style_parser.cpp b/src/mbgl/style/style_parser.cpp index 88d644f517..4c1fe593fc 100644 --- a/src/mbgl/style/style_parser.cpp +++ b/src/mbgl/style/style_parser.cpp @@ -156,12 +156,25 @@ void StyleParser::parseSources(const JSValue& value) { // parameters are specified inline. std::string url; + uint16_t tileSize = util::tileSize; + std::unique_ptr<SourceInfo> info; std::unique_ptr<mapbox::geojsonvt::GeoJSONVT> geojsonvt; switch (type) { - case SourceType::Vector: case SourceType::Raster: + if (sourceVal.HasMember("tileSize")) { + const JSValue& tileSizeVal = sourceVal["tileSize"]; + if (tileSizeVal.IsNumber() && tileSizeVal.GetUint64() <= std::numeric_limits<uint16_t>::max()) { + tileSize = tileSizeVal.GetUint64(); + } else { + Log::Error(Event::ParseStyle, "invalid tileSize"); + continue; + } + } + // Fall through. Vector sources are forbidden from having a tileSize. + + case SourceType::Vector: if (sourceVal.HasMember("url")) { const JSValue& urlVal = sourceVal["url"]; if (urlVal.IsString()) { @@ -208,7 +221,7 @@ void StyleParser::parseSources(const JSValue& value) { } const std::string id { nameVal.GetString(), nameVal.GetStringLength() }; - std::unique_ptr<Source> source = std::make_unique<Source>(type, id, url, std::move(info), std::move(geojsonvt)); + std::unique_ptr<Source> source = std::make_unique<Source>(type, id, url, tileSize, std::move(info), std::move(geojsonvt)); sourcesMap.emplace(id, source.get()); sources.emplace_back(std::move(source)); @@ -231,7 +244,6 @@ std::unique_ptr<mapbox::geojsonvt::GeoJSONVT> StyleParser::parseGeoJSON(const JS std::unique_ptr<SourceInfo> StyleParser::parseTileJSON(const JSValue& value) { auto info = std::make_unique<SourceInfo>(); parseTileJSONMember(value, info->tiles, "tiles"); - parseTileJSONMember(value, info->tile_size, "tileSize"); parseTileJSONMember(value, info->min_zoom, "minzoom"); parseTileJSONMember(value, info->max_zoom, "maxzoom"); parseTileJSONMember(value, info->attribution, "attribution"); |