diff options
author | Ansis Brammanis <brammanis@gmail.com> | 2016-03-30 12:20:55 -0700 |
---|---|---|
committer | Ansis Brammanis <brammanis@gmail.com> | 2016-03-30 13:57:47 -0700 |
commit | b6a181097c3e7c3168be3575d5d7e95820fc74ba (patch) | |
tree | 4f11720a5c0438176ab267dac9691597a3c4c531 /src | |
parent | 8e9e779f2fc8b7a8fa44204870afad51b87eb703 (diff) | |
download | qtlocation-mapboxgl-b6a181097c3e7c3168be3575d5d7e95820fc74ba.tar.gz |
[core] fix reparsing overscaled geojson tiles
fix #3838
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/annotation/shape_annotation_impl.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/source/source.cpp | 9 | ||||
-rw-r--r-- | src/mbgl/style/style_parser.cpp | 7 | ||||
-rw-r--r-- | src/mbgl/tile/geojson_tile.cpp | 2 |
4 files changed, 10 insertions, 10 deletions
diff --git a/src/mbgl/annotation/shape_annotation_impl.cpp b/src/mbgl/annotation/shape_annotation_impl.cpp index c333492810..cac5fa0725 100644 --- a/src/mbgl/annotation/shape_annotation_impl.cpp +++ b/src/mbgl/annotation/shape_annotation_impl.cpp @@ -114,7 +114,7 @@ void ShapeAnnotationImpl::updateTile(const TileID& tileID, AnnotationTile& tile) shapeTiler = std::make_unique<mapbox::geojsonvt::GeoJSONVT>(features, options); } - const auto& shapeTile = shapeTiler->getTile(tileID.z, tileID.x, tileID.y); + const auto& shapeTile = shapeTiler->getTile(tileID.sourceZ, tileID.x, tileID.y); if (!shapeTile) return; diff --git a/src/mbgl/source/source.cpp b/src/mbgl/source/source.cpp index 967a829ee9..262fc0871c 100644 --- a/src/mbgl/source/source.cpp +++ b/src/mbgl/source/source.cpp @@ -127,7 +127,7 @@ void Source::load(FileSource& fileSource) { info = std::move(newInfo); } else if (type == SourceType::GeoJSON) { - info = std::make_unique<SourceInfo>(); + std::unique_ptr<SourceInfo> newInfo = std::make_unique<SourceInfo>(); rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator> d; d.Parse<0>(res.data->c_str()); @@ -141,6 +141,9 @@ void Source::load(FileSource& fileSource) { geojsonvt = StyleParser::parseGeoJSON(d); reloadTiles = true; + + newInfo->maxZoom = geojsonvt->options.maxZoom; + info = std::move(newInfo); } if (reloadTiles) { @@ -352,9 +355,7 @@ bool Source::update(const StyleUpdateParameters& parameters) { int32_t maxCoveringZoom = util::clamp<int32_t>(zoom + 1, info->minZoom, info->maxZoom); if (zoom >= info->minZoom) { - const bool reparseOverscaled = - type == SourceType::Vector || - type == SourceType::Annotations; + const bool reparseOverscaled = type != SourceType::Raster; const auto actualZ = zoom; if (zoom > info->maxZoom) { diff --git a/src/mbgl/style/style_parser.cpp b/src/mbgl/style/style_parser.cpp index be26af56ad..cea0a95a22 100644 --- a/src/mbgl/style/style_parser.cpp +++ b/src/mbgl/style/style_parser.cpp @@ -203,6 +203,8 @@ void StyleParser::parseSources(const JSValue& value) { break; case SourceType::GeoJSON: + info = std::make_unique<SourceInfo>(); + // We should probably split this up to have URLs in the url property, and actual data // in the data property. Until then, we're going to detect the content based on the // object type. @@ -213,8 +215,8 @@ void StyleParser::parseSources(const JSValue& value) { url = { dataVal.GetString(), dataVal.GetStringLength() }; } else if (dataVal.IsObject()) { // We need to parse dataVal as a GeoJSON object - // TODO: parse GeoJSON data geojsonvt = parseGeoJSON(dataVal); + info->maxZoom = geojsonvt->options.maxZoom; } else { Log::Error(Event::ParseStyle, "GeoJSON data must be a URL or an object"); continue; @@ -224,9 +226,6 @@ void StyleParser::parseSources(const JSValue& value) { continue; } - // We always assume the default configuration for GeoJSON sources. - info = std::make_unique<SourceInfo>(); - break; default: diff --git a/src/mbgl/tile/geojson_tile.cpp b/src/mbgl/tile/geojson_tile.cpp index 31f2443ced..39cca01728 100644 --- a/src/mbgl/tile/geojson_tile.cpp +++ b/src/mbgl/tile/geojson_tile.cpp @@ -119,7 +119,7 @@ void GeoJSONTileMonitor::setGeoJSONVT(mapbox::geojsonvt::GeoJSONVT* vt) { void GeoJSONTileMonitor::update() { if (geojsonvt) { - auto tile = convertTile(geojsonvt->getTile(tileID.z, tileID.x, tileID.y)); + auto tile = convertTile(geojsonvt->getTile(tileID.sourceZ, tileID.x, tileID.y)); callback(nullptr, std::move(tile), {}, {}); } } |