Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
supercluster
Advanced tools
Supercluster is a fast, multi-purpose spatial clustering library for JavaScript. It is designed to handle large sets of geographical points and efficiently cluster them for visualization on maps. It is particularly useful for applications that need to display a large number of points on a map without overwhelming the user with too much information.
Creating a Cluster
This feature allows you to create a cluster from a set of geographical points. The code sample demonstrates how to initialize Supercluster, load points into it, and retrieve clusters for a specific zoom level and bounding box.
const Supercluster = require('supercluster');
const points = [
{ type: 'Feature', properties: {}, geometry: { type: 'Point', coordinates: [-73.97, 40.77] } },
{ type: 'Feature', properties: {}, geometry: { type: 'Point', coordinates: [-73.88, 40.78] } }
];
const index = new Supercluster({ radius: 40, maxZoom: 16 });
index.load(points);
const clusters = index.getClusters([-180, -85, 180, 85], 2);
console.log(clusters);
Getting Cluster Expansion Zoom
This feature allows you to get the zoom level at which a cluster expands into its constituent points. The code sample demonstrates how to initialize Supercluster, load points into it, and retrieve the expansion zoom level for a specific cluster.
const Supercluster = require('supercluster');
const points = [
{ type: 'Feature', properties: {}, geometry: { type: 'Point', coordinates: [-73.97, 40.77] } },
{ type: 'Feature', properties: {}, geometry: { type: 'Point', coordinates: [-73.88, 40.78] } }
];
const index = new Supercluster({ radius: 40, maxZoom: 16 });
index.load(points);
const zoom = index.getClusterExpansionZoom(1);
console.log(zoom);
KDBush is a very fast static spatial index for 2D points based on a flat KD-tree. It is useful for nearest neighbor queries and is often used in conjunction with Supercluster for efficient spatial indexing. Compared to Supercluster, KDBush is more focused on indexing and querying points rather than clustering them.
RBush is a high-performance JavaScript library for 2D spatial indexing of points and rectangles. It uses a R-tree data structure, which is optimized for spatial queries. While RBush can be used for clustering, it is more general-purpose and not as specialized for clustering large sets of points as Supercluster.
Geocluster is a simple and lightweight library for clustering geographical points. It uses a different algorithm compared to Supercluster and is more suitable for smaller datasets. Geocluster is easier to use but may not perform as well as Supercluster for very large datasets.
FAQs
A very fast geospatial point clustering library.
The npm package supercluster receives a total of 1,309,304 weekly downloads. As such, supercluster popularity was classified as popular.
We found that supercluster demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 29 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.