Skip to content

enforce TileJSON bounds - #4556

Merged
anandthakker merged 4 commits into
masterfrom
enforce-bounds
Apr 7, 2017
Merged

anandthakker merged 4 commits into
masterfrom
enforce-bounds

Conversation

@mollymerp

Copy link
Copy Markdown
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

@mollymerp mollymerp mentioned this pull request Apr 7, 2017
1 of 5 tasks
@mollymerp
mollymerp requested a review from anandthakker April 7, 2017 01:39

@anandthakker anandthakker left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread 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))]
];

Copy link
Copy Markdown
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
Copy Markdown
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

jlaxson commented Apr 7, 2017

Copy link
Copy Markdown

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

@mourner

mourner commented Apr 7, 2017

Copy link
Copy Markdown
Member

@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
Copy Markdown
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
Copy Markdown
Contributor

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

@mourner

mourner commented Apr 7, 2017 •

Copy link
Copy Markdown
Member

@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
Copy Markdown
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
Copy Markdown

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

kkaefer commented Aug 9, 2017

Copy link
Copy Markdown
Member

@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