Repository navigation
Support TileJSON bounds property - #10701
Conversation
e349b73 to
c3341bf
Compare
mollymerp
left a comment
There was a problem hiding this comment.
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.
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 ],
There was a problem hiding this comment.
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.
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.
kkaefer
left a comment
There was a problem hiding this comment.
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.
we should also verify that bottom <= top (and left <= right?)
| auto minX = std::floor(swProj.x); | ||
| auto maxX = std::ceil(neProj.x); | ||
| auto minY = std::floor(neProj.y); | ||
| auto maxY = std::ceil(swProj.y); |
| 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.
Does this check produce the same results as the one we're using for JS?
| tile = createTile(idealDataTileID); | ||
| assert(tile); | ||
| if(tile == nullptr) { | ||
| continue; |
There was a problem hiding this comment.
Can you please add a comment here that explains why tile might be null?
| // 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.
Can we change that to util::TileRange{} to make this code more readable?
There was a problem hiding this comment.
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.
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.boundsfrom being created inTilePyramid::update.