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

Implement TileJSON bounds property #3703

Closed
wants to merge 1 commit into from

Conversation

jlaxson
Copy link

@jlaxson jlaxson commented Nov 28, 2016

This is rough code to implement the bounds property in TileJSON to prevent loading/rendering tile data outside an extent. This functionality is useful for eliminating useless network roundtrips (that either result in 404 or an empty response) and eliminating lots and lots of error messages in the console in such a situation. Addresses #1775 and probably others.

If someone can confirm this is something you'd accept and 👍 the approach, I'll clean it up for inclusion.

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

@lucaswoj lucaswoj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR! 🙇 I'm excited to work with you to ship this feature soon.

this.cache[i] = [
[Math.floor(this.lngX(this.bounds.getWest(), i)), Math.floor(this.latY(this.bounds.getNorth(), i))],
[Math.ceil(this.lngX(this.bounds.getEast(), i)), Math.ceil(this.latY(this.bounds.getSouth(), i))]
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the performance impact of not caching these values and doing the calculations from scratch every time hasTile is called? If we could reduce the amount of state we hold & simplify this logic without a measurable perf impact, that'd be worth looking into.

serialize() {
return {
type: 'raster',
url: this.url,
tileSize: this.tileSize,
tiles: this.tiles
tiles: this.tiles,
bounds: this.bounds,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

serialize is expected to return a plain object (aka JSON serializable object, POJO). this.bounds is an instance of TileBounds. We'll need to think of a way to serialize this.bounds into a plain object, probably by writing a TileBounds#serialize method.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is why I kept both this.bounds as unmodified from what the client provides as well as storing the initialized object as this.tileBounds. The naming at the moment leaves something to be desired for sure. It seems preferable to me that TileBounds not need to worry about how to round-trip whatever source format the tile source uses?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I was tripped up by the naming of bounds vs tileBounds. Curious if there's a quick fix that would make this clearer, perhaps serializedBounds?

}
}

module.exports = TileBounds;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some linter errors in this file. You can see these errors on the CI build. You can run all the GL JS tests, including the linter, locally per these instructions.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah editor didn't pickup 4 spaces on the new file. Wanted to see that it was on the right track before spiffing up.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely on the right track. Spiff away! 👍 You may want to check if there's a plugin for your editor that supports the .editorconfig spec.

@jlaxson
Copy link
Author

jlaxson commented Nov 29, 2016

@lucaswoj how do you feel about the approach of delegating hasTile from SourceCache to the Source object? If good, I'll extend that to the vector tile source as well.

@lucaswoj
Copy link
Contributor

@lucaswoj how do you feel about the approach of delegating hasTile from SourceCache to the Source object? If good, I'll extend that to the vector tile source as well.

That sounds like the right thing to do. SourceCache should be as dumb as possible. 😄

@tgecho
Copy link

tgecho commented Dec 22, 2016

Any chance of movement on this? I'd be happy to help tidy up the lint issues, but the other changes will take a bit more for me to grok.

@lrlinde
Copy link

lrlinde commented Mar 14, 2017

Any chance this will be merged soon? Really looking forward to get this fixed! :)

@stackTom
Copy link

I'm also in need of this feature.

@mollymerp mollymerp mentioned this pull request Apr 7, 2017
5 tasks
@mollymerp
Copy link
Contributor

wrapping this up over at #4556 – thanks again @jlaxson!

@mollymerp mollymerp closed this Apr 7, 2017
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.

6 participants