Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ab05990

Browse files
committed
compute geo.midPt more efficiently
- and update non-clipped scroll test for more-pronounced signal
1 parent 5bc2c71 commit ab05990

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/plots/geo/geo.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ proto.updateProjection = function(fullLayout, geoLayout) {
194194
// px coordinates of view mid-point,
195195
// useful to update `geo.center` after interactions
196196
var midPt = this.midPt = [
197-
b[0][0] + (b[1][0] - b[0][0]) / 2,
198-
b[0][1] + (b[1][1] - b[0][1]) / 2
197+
(b[0][0] + b[1][0]) / 2,
198+
(b[0][1] + b[1][1]) / 2
199199
];
200200

201201
// adjust projection to user setting

src/plots/geo/layout/defaults.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function handleGeoDefaults(geoLayoutIn, geoLayoutOut, coerce) {
7878
var lon1 = lonRange[1];
7979
if(lon0 > 0 && lon1 < 0) lon1 += 360;
8080

81-
var centerLon = lon0 + (lon1 - lon0) / 2;
81+
var centerLon = (lon0 + lon1) / 2;
8282
var projLon;
8383

8484
if(!isAlbersUsa) {
@@ -109,7 +109,7 @@ function handleGeoDefaults(geoLayoutIn, geoLayoutOut, coerce) {
109109
centerLatDflt = 38.7;
110110
} else {
111111
centerLonDflt = isScoped ? centerLon : projLon;
112-
centerLatDflt = latRange[0] + (latRange[1] - latRange[0]) / 2;
112+
centerLatDflt = (latRange[0] + latRange[1]) / 2;
113113
}
114114

115115
coerce('center.lon', centerLonDflt);

test/jasmine/tests/geo_test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,13 +1544,13 @@ describe('Test geo zoom/pan/drag interactions:', function() {
15441544
], [
15451545
'geo.center.lat'
15461546
]);
1547-
return scroll([350, 250], [-200, -200]);
1547+
return scroll([200, 250], [-200, -200]);
15481548
})
15491549
.then(function() {
1550-
[-124.4, 0], [-124.4, 29.5], 1.3
15511550
_assert('after off-center scroll', [
1551+
[-151.2, 0], [-151.2, 29.5], 1.3
15521552
], [
1553-
[124.4, 0], [350, 329.2], [0, 0], 134.4
1553+
[151.2, 0], [350, 329.2], [0, 0], 134.4
15541554
], [
15551555
'geo.projection.rotation.lon',
15561556
'geo.center.lon', 'geo.center.lat',
@@ -1559,8 +1559,8 @@ describe('Test geo zoom/pan/drag interactions:', function() {
15591559
return Plotly.relayout(gd, 'geo.showocean', false);
15601560
})
15611561
.then(function() {
1562-
[-124.4, 0], [-124.4, 29.5], 1.3
15631562
_assert('after some relayout call that causes a replot', [
1563+
[-151.2, 0], [-151.2, 29.5], 1.3
15641564
], [
15651565
// converts translate (px) to center (lonlat)
15661566
[151.2, 0], [350, 260], [0, 29.5], 134.4

0 commit comments

Comments
 (0)