This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
[core] Fast tileCount with help from @mapbox/sphericalmercator module - #9906
Merged
Merged
Conversation
asheemmamoowala
force-pushed
the
9675-tile-count
branch
2 times, most recently
from
September 5, 2017 19:06
2fba28f to
65c1d27
Compare
jfirebaugh
reviewed
Sep 6, 2017
| assert(maxZ < std::numeric_limits<uint8_t>::max()); | ||
|
|
||
| unsigned long result = 0;; | ||
| for (auto z = minZ; z <= maxZ; z++) { |
| } | ||
|
|
||
| unsigned long OfflineTilePyramidRegionDefinition::tileCount(SourceType type, uint16_t tileSize, const Range<uint8_t>& zoomRange) const { | ||
| double minZ = std::max<double>(util::coveringZoomLevel(minZoom, type, tileSize), zoomRange.min); |
Contributor
There was a problem hiding this comment.
Can you refactor the code that's duplicated from tileCover into a function with the signature:
Range<uint8_t> coveringZoomRange(SourceType, uint16_t tileSize, const Range<uint8_t>& zoomRange) const|
|
||
| unsigned long result = 0;; | ||
| for (auto z = minZ; z <= maxZ; z++) { | ||
| auto count = util::tileCount(bounds, z, tileSize); |
Contributor
There was a problem hiding this comment.
result += util::tileCount(bounds, z, tileSize)
| } | ||
|
|
||
| // Project lat, lon to point in a zoom-dependent world size | ||
| static Point<double> project(const LatLng& point, uint8_t zoom, uint16_t tileSize) { |
Contributor
There was a problem hiding this comment.
Can this be written in terms of the existing project function, or vice versa?
asheemmamoowala
force-pushed
the
9675-tile-count
branch
2 times, most recently
from
September 6, 2017 21:29
8ddd56a to
0d732cb
Compare
jfirebaugh
approved these changes
Sep 8, 2017
Contributor
There was a problem hiding this comment.
Use static_cast rather than C-style cast.
asheemmamoowala
force-pushed
the
9675-tile-count
branch
from
September 8, 2017 23:59
0d732cb to
9b19ab7
Compare
kkaefer
reviewed
Sep 11, 2017
| std::vector<UnwrappedTileID> tileCover(const LatLngBounds&, int32_t z); | ||
|
|
||
| // Compute only the count of tiles needed for tileCover | ||
| unsigned long tileCount(const LatLngBounds&, uint8_t z, uint16_t tileSize); |
Member
There was a problem hiding this comment.
Can we please use fixed width number types (like uint64_t)? Unfortunately, unsigned long is 32 bit on some and 64 bit on other platforms.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #9675
Implement a separate
util::tileCount()method for computing the number of tiles that need to be downloaded for offline packs.The time for computing tile count for a bounding box around SF went from 12070 ms to 1 ms.
The failed attempts include:
tileCoveron the max zoom, and getting parents of those tiles up to min zoom. I was surprised by the cost ofboost::hash_combinewhich made this more expensive than runningtileCoverfor every zoom level.LatLngextents of the bounding box vsLatLngextents of a tile. This approached had way better performance but suffered from floating point errors due to the precision ofLatLngfor high zoom levels.Thanks to @jfirebaugh for pointing me to @mapbox/sphericalmercator