Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@peppsac
Copy link
Contributor

@peppsac peppsac commented Mar 1, 2018

Using https://github.com/mourner/flatbush speeds up the look up by a factor of 10.

For instance, on my computer and the panorama demo:

  • before the PR selectBestImageForExtent used to take 0.5ms to 3ms
  • after the PR: <= 0.1ms

Using https://github.com/mourner/flatbush speeds up the look up by a factor of 10.

For instance, on my computer and the panorama demo:
  - before the PR selectBestImageForExtent used to take 0.5ms to 3ms
  - after the PR: <= 0.1ms
}
layer._spatialIndex = FlatBush(layer.images.length);
for (const image of layer.images) {
layer._spatialIndex.add(
Copy link
Contributor

Choose a reason for hiding this comment

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

You could merge this loop with the one above. Or did I miss something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need to know the number of images to initialize the index.
And metadata is a json object, so I'm not sure how to get the number of images before the loop?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh right, it's a for..in, not a for..of loop

for (const entry of layer.images) {
if (tile.extent.isInside(entry.extent)) {
return true;
if (tile.extent.crs() == layer.extent.crs()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

providing that Extent.isInside starts by doing other.as(this._crs), why can't we use the spatial index in all cases by doing a tile.extent.as(layer.extent.crs()) first?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll change that.

@autra
Copy link
Contributor

autra commented Mar 6, 2018

LGTM thanks!

@autra autra merged commit d4ec447 into master Mar 6, 2018
@autra autra deleted the feat_protocols_spatial_hash branch March 6, 2018 14:33
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.

3 participants