Skip to content

Commit 3597df2

Browse files
committed
Address review feedback on antimeridian fitbounds
- Guard against an empty locations array (truthy [] should not count as region data) - Clarify the comment on why the compact-range path is restricted to fitbounds='locations' with no region-bearing traces - Tighten the projection rotation assertion in the straddling test
1 parent c104f33 commit 3597df2

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

src/plots/geo/geo.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,10 @@ proto.updateProjection = function(geoCalcData, fullLayout) {
236236

237237
// For point data straddling the antimeridian (±180°), the naive [min, max]
238238
// longitude range above can include a large empty span; prefer the compact
239-
// crossing range instead. Skipped when a trace contributes region extents
240-
// (choropleth or location-based scattergeo), whose geographic bounds are not
241-
// captured by the point longitudes gathered here.
239+
// crossing range instead. Restricted to fitbounds='locations' with no
240+
// region-bearing traces: choropleth, scattergeo `locations`, and the
241+
// geojson-bbox path used by fitbounds='geojson' + locationmode='geojson-id'
242+
// all carry region extents that per-point lonlat centroids don't capture.
242243
if(!this.hasChoropleth && geoLayout.fitbounds === 'locations') {
243244
var lons = [];
244245
var hasLocationData = false;
@@ -249,7 +250,7 @@ proto.updateProjection = function(geoCalcData, fullLayout) {
249250

250251
// only visible traces contribute to the autorange above
251252
if(fitTrace.visible !== true) continue;
252-
if(fitTrace.locations) {
253+
if(fitTrace.locations?.length) {
253254
hasLocationData = true;
254255
break;
255256
}

test/jasmine/tests/geo_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ describe('Test geo fitbounds with antimeridian-straddling points', function() {
9595
expect(lonRange[1]).toBeGreaterThan(181);
9696
expect(lonRange[1] - lonRange[0]).toBeGreaterThan(49);
9797
expect(lonRange[1] - lonRange[0]).toBeLessThan(70);
98-
expect(geoLayout._subplot.projection.rotate()[0]).toBeCloseTo(-156.4, 0);
98+
expect(geoLayout._subplot.projection.rotate()[0]).toBeCloseTo(-156.44, 1);
9999
})
100100
.then(done, done.fail);
101101
});

0 commit comments

Comments
 (0)