-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[WIP] [ios, macos] Calculate number of tiles for an offline region #11965
Conversation
@@ -53,6 +53,11 @@ - (instancetype)initWithStyleURL:(NSURL *)styleURL bounds:(MGLCoordinateBounds)b | |||
return self; | |||
} | |||
|
|||
-(uint64_t)tileCount { | |||
auto tilePyramidOfflineRegion = [self offlineRegionDefinition]; | |||
return tilePyramidOfflineRegion.tileCount(mbgl::style::SourceType::Vector, 512, {static_cast<unsigned char>(tilePyramidOfflineRegion.minZoom), static_cast<unsigned char>(tilePyramidOfflineRegion.maxZoom)}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For testing purposes, I'm assuming the source type and tile size. We will need to figure out a way for to pass these in dynamically, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asheemmamoowala, it would be great if this method could somehow call tileCount()
automatically for each source in the style, so that the developer doesn’t have to enumerate the sources themselves. But I’m unsure how we could accomplish that for arbitrary style URLs, especially if the URL hasn’t been loaded yet. #6386 would make it possible to pass in a full style in some cases, but there’s still the possibility of an unloaded style.
In the meantime, perhaps we could make it a method of MGLTileSource that takes an offline region as a parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the meantime, perhaps we could make it a method of MGLTileSource that takes an offline region as a parameter?
I like this approach. Another option is to extend MGLOfflineRegion...
to use the currently loaded MGLStyle
, and the MGLStlye.sources
property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The offline map API and runtime styling APIs currently have little to do with each other. I think it would be problematic if we hooked up MGLOfflinePack or MGLOfflineRegion with MGLStyle in any way, because that would imply you could add a source to the style and have it reflected in the tile count, or change a layer in the style and persist that change when loading the offline pack in the future.
For now, let’s turn the MGLOfflineRegion.tileCount
property into a method that takes an MGLTileSource as a parameter. We can frame it as a way to get the tile count for a single source within the offline pack. Then the developer can create an MGLTileSource to pass into this method. The MGLTileSource knows all the details we need for that tileCount()
call even without loading the style.
It’ll be a bit weird that the developer will be able to pass an unrelated source into this method, but that weirdness comes from how the style URL is part of the offline region, something we can’t change just yet.
@@ -10,6 +10,12 @@ NS_ASSUME_NONNULL_BEGIN | |||
*/ | |||
@protocol MGLOfflineRegion <NSObject> | |||
|
|||
/** | |||
The number of tiles that the object conforming to the `MGLOfflineRegion` | |||
protocol contains. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More precisely, it’s the number of tiles needed to load one of the style’s sources within the region.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This is still in flight. |
This pull request has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions. |
This is quite outdated, and I'm worried we might need to scrap this and start over with a fresh implementation if things have changed. @1ec5 what do you think? |
This pull request has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions. |
Draft implementation for #11504
Adds a new method which calculates the number of tiles within an
MGLTilePyramidOfflineRegion
.This is implemented within the
MGLOfflineRegion
protocol in hopes of this one day applying to offline regions with arbitrary shapes, as mentioned in #11447. This is very much a work in progress.