mapbox / mapbox/supercluster

Missing points when bounds are scoped to the extent of points

Open
#234 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
JavaScript
Stars
2.4k
Forks
304
PR merge metrics
No merged PRs in 30d

Description

I've noticed this (inconsistently) on several occasions: when the bounds that are used to create the bbox sent to Supercluster are created by iterating over them and extending the bounds to each point's geometry, sometimes points get left out. I have a working CodeSandbox to reproduce this: https://codesandbox.io/s/supercluster-points-8kqttt.

In this example, the points are:

const features = [
  {
    type: "Feature",
    properties: {
      isUser: true,
      userId: "5"
    },
    geometry: {
      type: "Point",
      coordinates: [-123.211605, 43.972615]
    }
  },
  {
    type: "Feature",
    properties: {
      isUser: true,
      userId: "3"
    },
    geometry: {
      type: "Point",
      coordinates: [-123.245515, 43.9150233333333]
    }
  },
  {
    type: "Feature",
    properties: {
      isUser: true,
      userId: "16"
    },
    geometry: {
      type: "Point",
      coordinates: [-123.192528333333, 44.0307166666667]
    }
  },
  {
    type: "Feature",
    properties: {
      state: "old",
      userId: "8"
    },
    geometry: {
      type: "Point",
      coordinates: [-123.194573333333, 44.0107]
    }
  }
];

The bbox that gets passed to supercluster ends up being [-123.245515, 43.9150233333333, -123.192528333333, 44.0307166666667]. The point that gets left out (ie not contained within a cluster, but not returned as an individual point either) has the coordinates [-123.245515, 43.9150233333333], which represents the southwest corner of the bbox. It would make more sense to me if both that and the point with userId: "16" were both left out, since point 16 represents the northeast corner of the bbox, but point 16 is consistently returned.

This is definitely an edge case (literally, on the edge of the bounding box, get it...), but I'm curious to understand what's going on.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodeSandbox reproduction and trace how Supercluster handles the bbox whose southwest and northeast corners are point coordinates. Inspect the bbox query and clustering behavior around boundary points, then add a regression check showing that the reproduced points are consistently accounted for.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.