-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Conversation
e349b73
to
c3341bf
Compare
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.
Sorry for the delay! This looks good to me with a caveat in the comments about bounds wrapping.
Also I'm not very familiar with the tile loading logic in native so definitely a good idea to have @kkaefer or someone else take a second look!
|
||
bool contains(const CanonicalTileID& tileID) { | ||
return z == tileID.z && | ||
(range.min.x >= range.max.x ? //For wrapped bounds |
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.
fwiw I don't think wrapped bounds are supported in TileJSON – I'm not sure if wrapped (i.e. > 180 || < -180
) latitudes are considered to be true WSG:84 coordinates but 🤷♀️
// OPTIONAL. Default: [-180, -90, 180, 90].
// The maximum extent of available map tiles. Bounds MUST define an area
// covered by all zoom levels. The bounds are represented in WGS:84
// latitude and longitude values, in the order left, bottom, right, top.
// Values may be integers or floating point numbers.
"bounds": [ -180, -85.05112877980659, 180, 85.0511287798066 ],
https://github.com/mapbox/tilejson-spec/tree/master/2.2.0
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 JS implementation we also clamp the bounds, so this would introduce differing behavior between the two packages
https://github.com/mapbox/mapbox-gl-js/blob/2124161ebba0c17d764e2e7f78e2d34a283e9bae/src/source/tile_bounds.js#L22
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 input coordinates can easily be clamped, but if left> right, it will result in the unwrapped bounds in native, and invalid bounds in JS, where the contains
test will always fail on longitude here.
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.
Looks good! Can you please also add render tests that attempt to render tiles that are on the fringe/outside of the tile bounds to verify that they aren't rendered?
if (!validateLatitude(*bottom) || !validateLatitude(*top)){ | ||
error = { "bounds latitude values must be between -90 and 90" }; | ||
return {}; | ||
} |
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.
we should also verify that bottom <= top (and left <= right?)
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.
src/mbgl/util/tile_range.hpp
Outdated
auto minX = std::floor(swProj.x); | ||
auto maxX = std::ceil(neProj.x); | ||
auto minY = std::floor(neProj.y); | ||
auto maxY = std::ceil(swProj.y); |
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.
const
all the things
src/mbgl/util/tile_range.hpp
Outdated
tileID.x < range.max.x && | ||
tileID.x >= range.min.x && | ||
tileID.y < range.max.y && | ||
tileID.y >= range.min.y; |
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.
Does this check produce the same results as the one we're using for JS?
@@ -35,7 +35,9 @@ void updateRenderables(GetTileFn getTile, | |||
auto tile = getTile(idealDataTileID); | |||
if (!tile) { | |||
tile = createTile(idealDataTileID); | |||
assert(tile); | |||
if(tile == nullptr) { | |||
continue; |
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.
Can you please add a comment here that explains why tile
might be null
?
@@ -41,6 +41,7 @@ void RenderAnnotationSource::update(Immutable<style::Source::Impl> baseImpl_, | |||
// Zoom level 16 is typically sufficient for annotations. | |||
// See https://github.com/mapbox/mapbox-gl-native/issues/10197 | |||
{ 0, 16 }, | |||
{}, |
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.
Can we change that to util::TileRange{}
to make this code more readable?
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.
That parameter represents an optional<LatLngBounds>
. Are you suggesting to change the type of the parameter to TilePyramid::update
?
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.
No, just writing the type here to make it explicit when reading the code.
3783fb2
to
7b2d2a1
Compare
Move LatLngBounds::contains impl to cpp file
…instead of LatLngBounds comparisons for tiles.
7b2d2a1
to
ef7b673
Compare
* [core] Parse TileJSON bounds property * [core] Add TileRange and LatLngBounds::contains(CanonicalTileID) Move LatLngBounds::contains impl to cpp file * [core] Skip tile creation outside of tileset bounds * [core] Fix TileRange for wrapped bounds and use for CustomTileLoader instead of LatLngBounds comparisons for tiles.
* [core] Parse TileJSON bounds property * [core] Add TileRange and LatLngBounds::contains(CanonicalTileID) Move LatLngBounds::contains impl to cpp file * [core] Skip tile creation outside of tileset bounds * [core] Fix TileRange for wrapped bounds and use for CustomTileLoader instead of LatLngBounds comparisons for tiles.
Closes #5394.
Prevent tiles outside of
TileJSON.bounds
from being created inTilePyramid::update
.