-
-
Notifications
You must be signed in to change notification settings - Fork 754
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
Fix cluster radius scaling in setClusterOptions #5055
Conversation
8c725b6
to
8d68acd
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5055 +/- ##
==========================================
- Coverage 89.06% 89.06% -0.01%
==========================================
Files 269 269
Lines 38318 38320 +2
Branches 2362 2366 +4
==========================================
+ Hits 34129 34130 +1
+ Misses 3187 3183 -4
- Partials 1002 1007 +5 ☔ View full report in Codecov by Sentry. |
Thanks! I would advise to add a test to this case or modify an existing one. |
8d68acd
to
f99007d
Compare
@HarelM |
Thanks! |
src/source/geojson_source.test.ts
Outdated
extent: 8192, | ||
radius: 1600, | ||
extent: EXTENT, | ||
radius: 100 * EXTENT / 512, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the hard coded 512?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve replaced the hardcoded 512
with source.tileSize
.
src/source/geojson_source.ts
Outdated
@@ -182,7 +182,7 @@ export class GeoJSONSource extends Evented implements Source { | |||
maxZoom: options.clusterMaxZoom !== undefined ? options.clusterMaxZoom : this.maxzoom - 1, | |||
minPoints: Math.max(2, options.clusterMinPoints || 2), | |||
extent: EXTENT, | |||
radius: (options.clusterRadius || 50) * scale, | |||
radius: this._scaleClusterRadius(options.clusterRadius || 50), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use the same method to scale the buffer
input field, and rename it accordingly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed the method to _pixelsToTileUnits
and applied it to scale those fields as well.
Added a few nitpicking, looks good otherwise, THANKS! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
The calculation for
superclusterOptions.radius
inGeoJSONSource.setClusterOptions
is missing the necessary scaling, resulting in incorrect values.For reference, the relevant initialization code can be found here:
maplibre-gl-js/src/source/geojson_source.ts
Line 160 in bc43205
maplibre-gl-js/src/source/geojson_source.ts
Line 185 in bc43205
Note:
setClusterOptions
was introduced in #1998.Launch Checklist