Skip to content
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

Merged
merged 4 commits into from
Apr 7, 2017
Merged

enforce TileJSON bounds #4556

merged 4 commits into from
Apr 7, 2017

Conversation

mollymerp
Copy link
Contributor

wraps up #3703 -- thank you @jlaxson for your contribution!
closes #1775

cc @vincentsarago @anandthakker

Launch Checklist

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • document any changes to public APIs
  • post benchmark scores
  • manually test the debug page

Copy link
Contributor

@anandthakker anandthakker left a 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.

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))]
];
Copy link
Contributor

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 consts minX, minY, etc.?

t.true(source.hasTile({z: 8, x:95, y: 132}), 'returns true for tiles inside bounds');
t.end();
});

Copy link
Contributor

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 uses hasTile() to filter which tiles it loads.

@anandthakker anandthakker merged commit 8fd6e00 into master Apr 7, 2017
@anandthakker anandthakker deleted the enforce-bounds branch April 7, 2017 19:41
@jlaxson
Copy link

jlaxson commented Apr 7, 2017

Wow. This is awesome, thanks @mollymerp. Can't believe I never got back to this after Thanksgiving (!).

@mourner
Copy link
Member

mourner commented Apr 7, 2017

@mollymerp looks like we now have some code duplication between the new tile_bounds.js and transform (which also has projection code). Can we get rid of the first and reuse the transform methods?

@anandthakker
Copy link
Contributor

@mourner we'd need to extract the common calculation into util, because they aren't 100% identical (the 'world size' differs), and also because using transform directly would introduce an unnecessary dependency of TileBounds on Transform.

@anandthakker
Copy link
Contributor

I'm also not convinced that avoiding one duplication is critical...

@mourner
Copy link
Member

mourner commented Apr 7, 2017

@anandthakker I mean, not directly instantiating Transform in TileBounds, but rather using map.transform methods (e.g. locationCoordinate) directly in RasterTileSource to avoid introducing TileBounds class altogether. This is not critical, but code simplification is always welcome. We can do this later (certainly not necessary before release).

@anandthakker
Copy link
Contributor

rather using map.transform methods (e.g. locationCoordinate) directly in RasterTileSource

Hm, along the lines of #3350, I would be hesitant to increase any Source's reliance on the parent Map object.

@underbluewaters
Copy link

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.

@kkaefer
Copy link
Member

kkaefer commented Aug 9, 2017

@underbluewaters good call. The source class is a combination of TileJSON (which does have this property), and a few custom properties. Ticketed in #5124

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support bounds in TileJSON
6 participants