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

add getLeaves method for retrieving leaf points (paginated) #32

Merged
merged 2 commits into from
Jan 18, 2017

Conversation

mourner
Copy link
Member

@mourner mourner commented Jan 18, 2017

Building on #31, this PR adds a method for a super-fast retrieval of leaf points in a cluster with pagination support. This is the second part of solving mapbox/mapbox-gl-js#3318, allowing us to create a UI where you can click on a cluster and get a paginated view of all points in it with ability to jump between pages.

Usage is as follows:

index.getLeaves(
    clusterId, // cluster_id property of the clicked cluster
    zoom,      // zoom of the clicked cluster
    limit,     // how many points to return; 10 by default
    offset);   // how many points to skip for pagination; 0 by default

Since this is basically depth-first spatial tree traversal, the call is very fast — e.g. getting 1000 points starting from the 200,000-th from a 400,000-point cluster takes just 2-3ms. Getting an array of all 400k points (limit = Infinity, offset = 0) takes 220ms, which is surprisingly fast too.

  • add some tests

cc @apkoponen @bewithjonam @stepankuzmin @popovae

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

Successfully merging this pull request may close these issues.

1 participant