-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enforce TileJSON bounds #4556
enforce TileJSON bounds #4556
Conversation
e49d03e
to
af31877
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.
Nice, this looks great! Just one nit and a couple more unit tests that I think we should add.
src/source/tile_bounds.js
Outdated
const level = [ | ||
[Math.floor(this.lngX(this.bounds.getWest(), coord.z)), Math.floor(this.latY(this.bounds.getNorth(), coord.z))], | ||
[Math.ceil(this.lngX(this.bounds.getEast(), coord.z)), Math.ceil(this.latY(this.bounds.getSouth(), coord.z))] | ||
]; |
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.
nit: for readability, instead of an array, could this be four individual const
s minX
, minY
, etc.?
t.true(source.hasTile({z: 8, x:95, y: 132}), 'returns true for tiles inside bounds'); | ||
t.end(); | ||
}); | ||
|
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.
Let's also include tests:
- for the case where
bounds
is included directly on the TileJSON (i.e. where the source is created with{url: ...}
- equivalent ones for raster source
- in
source_cache.test.js
, confirming that SourceCache useshasTile()
to filter which tiles it loads.
Wow. This is awesome, thanks @mollymerp. Can't believe I never got back to this after Thanksgiving (!). |
@mollymerp looks like we now have some code duplication between the new |
@mourner we'd need to extract the common calculation into |
I'm also not convinced that avoiding one duplication is critical... |
@anandthakker I mean, not directly instantiating |
Hm, along the lines of #3350, I would be hesitant to increase any |
Any reason this bounds parameter isn't in the tile spec Sources documentation? I was wondering if just this feature was supported but I had to dig through the tickets here. |
@underbluewaters good call. The source class is a combination of TileJSON (which does have this property), and a few custom properties. Ticketed in #5124 |
wraps up #3703 -- thank you @jlaxson for your contribution!
closes #1775
cc @vincentsarago @anandthakker
Launch Checklist