openwisp / openwisp/netjsongraph.js
[change] Include polygon locations in geographic-map clustering
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 314
- Forks
- 119
- Avg merge
- 18h 17m
- Merged PRs (30d)
- 15
Description
Is your change related to a problem? Please describe.
Point locations participate in NetJSONGraph's geographic-map clusters, while Polygon and MultiPolygon locations remain visible at every zoom level. This creates visual clutter and makes polygons inconsistent with point locations at low zoom levels.
The current architecture explains the behavior: GeoJSON points are converted to internal nodes and clustered by the KDBush-based clustering code, while polygons are excluded from conversion and rendered as a separate Leaflet L.geoJSON layer. Cluster updates only replace ECharts data, so they cannot hide or reveal polygon layers.
Describe the solution you'd like
Change geographic-map clustering so polygons and multipolygons can participate alongside points.
Each polygon should have a stable representative coordinate, preferably a point guaranteed to lie within the geometry. That representative coordinate should be eligible for clustering while retaining an association with the corresponding Leaflet feature layer. When a polygon belongs to a collapsed cluster, its geometry should be hidden. It should be restored when the cluster expands through zooming or when clustering is disabled at the configured zoom level.
The behavior should support mixed point and polygon GeoJSON collections, multipolygons, stable feature identity, and cluster clicks that continue to zoom into the relevant area.
Describe alternatives you've considered
A consumer can hide all polygons below a fixed zoom level and show all of them above it. This is only an approximation because it cannot associate a polygon with a particular cluster or reveal it as that cluster expands.
Adding synthetic centroid point features in the consumer would also be brittle. It duplicates geometry state and still requires consumer code to synchronize cluster membership with Leaflet layer visibility.
Additional context
This is a change to NetJSONGraph rather than an OpenWISP Monitoring-only change because the GeoJSON conversion, clustering algorithm, and polygon-layer lifecycle are owned by NetJSONGraph. The implementation should add focused tests for point and polygon clusters, polygon visibility across zoom levels, and multipolygon behavior.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the GeoJSON conversion and KDBush-based clustering code, then inspect the separate Leaflet L.geoJSON polygon layer and the ECharts cluster-update path. Add focused tests for mixed point and polygon clusters, visibility across zoom levels, stable feature identity, cluster clicks, and multipolygons; done means polygon layers hide in collapsed clusters and reappear when expanded or clustering is disabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- data-visualization, frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100