summaryrefslogtreecommitdiff
path: root/src/mbgl
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2017-03-21 16:28:11 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2017-03-21 19:33:36 +0200
commit1f8910de186f35216791a17a683a55f01031ec81 (patch)
treeee470e8e1ee6f85094afce6d1a227018b9780eb6 /src/mbgl
parent86cddaf751e4c66f117b28fb013a43486581c948 (diff)
downloadqtlocation-mapboxgl-1f8910de186f35216791a17a683a55f01031ec81.tar.gz
Make Source::getZoomRange return an optional range
Diffstat (limited to 'src/mbgl')
-rw-r--r--src/mbgl/annotation/annotation_source.cpp4
-rw-r--r--src/mbgl/annotation/annotation_source.hpp3
-rw-r--r--src/mbgl/style/source.cpp2
-rw-r--r--src/mbgl/style/source_impl.cpp8
-rw-r--r--src/mbgl/style/source_impl.hpp2
-rw-r--r--src/mbgl/style/sources/geojson_source_impl.cpp8
-rw-r--r--src/mbgl/style/sources/geojson_source_impl.hpp2
-rw-r--r--src/mbgl/style/tile_source_impl.cpp8
-rw-r--r--src/mbgl/style/tile_source_impl.hpp3
9 files changed, 22 insertions, 18 deletions
diff --git a/src/mbgl/annotation/annotation_source.cpp b/src/mbgl/annotation/annotation_source.cpp
index 7434029c4b..c52836c500 100644
--- a/src/mbgl/annotation/annotation_source.cpp
+++ b/src/mbgl/annotation/annotation_source.cpp
@@ -14,8 +14,8 @@ AnnotationSource::Impl::Impl(Source& base_)
: Source::Impl(SourceType::Annotations, AnnotationManager::SourceID, base_) {
}
-Range<uint8_t> AnnotationSource::Impl::getZoomRange() const {
- return { 0, 22 };
+optional<Range<uint8_t>> AnnotationSource::Impl::getZoomRange() const {
+ return { { 0, 22 } };
}
void AnnotationSource::Impl::loadDescription(FileSource&) {
diff --git a/src/mbgl/annotation/annotation_source.hpp b/src/mbgl/annotation/annotation_source.hpp
index 62d1aa3488..07e00dc52d 100644
--- a/src/mbgl/annotation/annotation_source.hpp
+++ b/src/mbgl/annotation/annotation_source.hpp
@@ -18,9 +18,10 @@ public:
void loadDescription(FileSource&) final;
+ optional<Range<uint8_t>> getZoomRange() const final;
+
private:
uint16_t getTileSize() const final { return util::tileSize; }
- Range<uint8_t> getZoomRange() const final;
std::unique_ptr<Tile> createTile(const OverscaledTileID&, const style::UpdateParameters&) final;
};
diff --git a/src/mbgl/style/source.cpp b/src/mbgl/style/source.cpp
index 9ef245ac34..f10fc6916b 100644
--- a/src/mbgl/style/source.cpp
+++ b/src/mbgl/style/source.cpp
@@ -18,7 +18,7 @@ optional<std::string> Source::getAttribution() const {
return baseImpl->getAttribution();
}
-Range<uint8_t> Source::getZoomRange() const {
+optional<Range<uint8_t>> Source::getZoomRange() const {
return baseImpl->getZoomRange();
}
diff --git a/src/mbgl/style/source_impl.cpp b/src/mbgl/style/source_impl.cpp
index 1f8301629f..356d420e19 100644
--- a/src/mbgl/style/source_impl.cpp
+++ b/src/mbgl/style/source_impl.cpp
@@ -91,15 +91,15 @@ void Source::Impl::updateTiles(const UpdateParameters& parameters) {
}
const uint16_t tileSize = getTileSize();
- const Range<uint8_t> zoomRange = getZoomRange();
+ const optional<Range<uint8_t>> zoomRange = getZoomRange();
// Determine the overzooming/underzooming amounts and required tiles.
int32_t overscaledZoom = util::coveringZoomLevel(parameters.transformState.getZoom(), type, tileSize);
int32_t tileZoom = overscaledZoom;
std::vector<UnwrappedTileID> idealTiles;
- if (overscaledZoom >= zoomRange.min) {
- int32_t idealZoom = std::min<int32_t>(zoomRange.max, overscaledZoom);
+ if (overscaledZoom >= zoomRange->min) {
+ int32_t idealZoom = std::min<int32_t>(zoomRange->max, overscaledZoom);
// Make sure we're not reparsing overzoomed raster tiles.
if (type == SourceType::Raster) {
@@ -142,7 +142,7 @@ void Source::Impl::updateTiles(const UpdateParameters& parameters) {
renderTiles.clear();
algorithm::updateRenderables(getTileFn, createTileFn, retainTileFn, renderTileFn,
- idealTiles, zoomRange, tileZoom);
+ idealTiles, *zoomRange, tileZoom);
if (type != SourceType::Annotations) {
size_t conservativeCacheSize =
diff --git a/src/mbgl/style/source_impl.hpp b/src/mbgl/style/source_impl.hpp
index fbec2b0eba..b4941dc638 100644
--- a/src/mbgl/style/source_impl.hpp
+++ b/src/mbgl/style/source_impl.hpp
@@ -83,7 +83,7 @@ public:
const std::string id;
virtual optional<std::string> getAttribution() const { return {}; };
- virtual Range<uint8_t> getZoomRange() const = 0;
+ virtual optional<Range<uint8_t>> getZoomRange() const = 0;
bool loaded = false;
diff --git a/src/mbgl/style/sources/geojson_source_impl.cpp b/src/mbgl/style/sources/geojson_source_impl.cpp
index 5ceb4f71e0..b050e5482e 100644
--- a/src/mbgl/style/sources/geojson_source_impl.cpp
+++ b/src/mbgl/style/sources/geojson_source_impl.cpp
@@ -153,9 +153,11 @@ void GeoJSONSource::Impl::loadDescription(FileSource& fileSource) {
});
}
-Range<uint8_t> GeoJSONSource::Impl::getZoomRange() const {
- assert(loaded);
- return { 0, options.maxzoom };
+optional<Range<uint8_t>> GeoJSONSource::Impl::getZoomRange() const {
+ if (loaded) {
+ return { { 0, options.maxzoom }};
+ }
+ return {};
}
std::unique_ptr<Tile> GeoJSONSource::Impl::createTile(const OverscaledTileID& tileID,
diff --git a/src/mbgl/style/sources/geojson_source_impl.hpp b/src/mbgl/style/sources/geojson_source_impl.hpp
index 05302d6bc0..b827a0b26c 100644
--- a/src/mbgl/style/sources/geojson_source_impl.hpp
+++ b/src/mbgl/style/sources/geojson_source_impl.hpp
@@ -28,7 +28,7 @@ public:
return util::tileSize;
}
- Range<uint8_t> getZoomRange() const final;
+ optional<Range<uint8_t>> getZoomRange() const final;
private:
void _setGeoJSON(const GeoJSON&);
diff --git a/src/mbgl/style/tile_source_impl.cpp b/src/mbgl/style/tile_source_impl.cpp
index 44fb01b0ee..daa6389a8e 100644
--- a/src/mbgl/style/tile_source_impl.cpp
+++ b/src/mbgl/style/tile_source_impl.cpp
@@ -113,9 +113,11 @@ void TileSourceImpl::loadDescription(FileSource& fileSource) {
});
}
-Range<uint8_t> TileSourceImpl::getZoomRange() const {
- assert(loaded);
- return tileset.zoomRange;
+optional<Range<uint8_t>> TileSourceImpl::getZoomRange() const {
+ if (loaded) {
+ return tileset.zoomRange;
+ }
+ return {};
}
optional<std::string> TileSourceImpl::getAttribution() const {
diff --git a/src/mbgl/style/tile_source_impl.hpp b/src/mbgl/style/tile_source_impl.hpp
index 1fda3b3769..2993caf20a 100644
--- a/src/mbgl/style/tile_source_impl.hpp
+++ b/src/mbgl/style/tile_source_impl.hpp
@@ -35,8 +35,7 @@ public:
}
optional<std::string> getAttribution() const override;
-
- Range<uint8_t> getZoomRange() const final;
+ optional<Range<uint8_t>> getZoomRange() const final;
protected:
const variant<std::string, Tileset> urlOrTileset;