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

Handle invalid input more gracefully #128

Open
ademidun opened this issue Jul 4, 2019 · 2 comments
Open

Handle invalid input more gracefully #128

ademidun opened this issue Jul 4, 2019 · 2 comments

Comments

@ademidun
Copy link

ademidun commented Jul 4, 2019

Some of my zoom levels are returning an empty list cluster, while other zoom levels are properly returning a list of clusters.

Screen Shot 2019-07-04 at 4 02 45 PM

  const index = new Supercluster({
    radius: 200,
    maxZoom: 16,
  });
  index.load(markers);
  const clusterResponse = {};

  const ZOOM_LEVELS = [9, 10, 11, 12, 13, 14, 15];
  ZOOM_LEVELS.forEach((zoomLevel) => {
    const clusters = index.getClusters([-180, -85, 180, 85], zoomLevel);
    clusterResponse[zoomLevel.toString()] = clusters
      .map(cluster => ({
        id: cluster.id || cluster.properties.id,
        count: cluster.properties.cluster ? cluster.properties.point_count : 1,
        longitude: cluster.geometry.coordinates[0],
        latitude: cluster.geometry.coordinates[1],
      }));
  });
@mourner
Copy link
Member

mourner commented Jul 5, 2019

Can you please provide a full reproducible minimal test case (including data)? There's isn't enough information to diagnose the issue.

@ademidun
Copy link
Author

It turns out the problem is that if you have a list of markers and one of the points has a null latitude or longitude. All the clusters will fail to be created. Even if all the other markers have valid latitude or longitudes.

You can recreate it yourself if you have a list of markers with lat long values and set one of the points lat or long values to null.

I think this is a bug, currently we are working around it ourselves by filtering out points with lat or long. But I think the expected behavior would be:

  1. index. load() function to filter out invalid markers.

  2. A warning could be raised to let user know Warning: 5 markers were dropped due to invalid lat or long values

  3. Create a function index.getWarningMessages() to let the user know that certain points had to be filtered out due to invalid lat or long values and let the user know what points those were.

Here is the current workaround we are doing

const filteredMarkers = markers.map(marker => marker.latitude && marker.longitude)

@mourner curious to hear your thoughts?

@mourner mourner reopened this Jul 16, 2019
@mourner mourner changed the title SuperCluster returning an empty array list for certain zoom levels Handle invalid input more gracefully Jul 16, 2019
@itzsaga itzsaga mentioned this issue Aug 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants