@@ -379,8 +379,8 @@ define([
379
379
var startCartographicScratch = new Cartographic ( ) ;
380
380
var endCartographicScratch = new Cartographic ( ) ;
381
381
var idlCross = {
382
- west : 0.0 ,
383
- east : 0.0
382
+ westOverIDL : 0.0 ,
383
+ eastOverIDL : 0.0
384
384
} ;
385
385
var ellipsoidGeodesic = new EllipsoidGeodesic ( ) ;
386
386
function computeRectangle ( positions , ellipsoid , arcType , granularity , result ) {
@@ -406,8 +406,8 @@ define([
406
406
result . south = Number . POSITIVE_INFINITY ;
407
407
result . north = Number . NEGATIVE_INFINITY ;
408
408
409
- idlCross . west = Number . POSITIVE_INFINITY ;
410
- idlCross . east = Number . NEGATIVE_INFINITY ;
409
+ idlCross . westOverIDL = Number . POSITIVE_INFINITY ;
410
+ idlCross . eastOverIDL = Number . NEGATIVE_INFINITY ;
411
411
412
412
var inverseChordLength = 1.0 / CesiumMath . chordLength ( granularity , ellipsoid . maximumRadius ) ;
413
413
var positionsLength = positions . length ;
@@ -429,9 +429,16 @@ define([
429
429
ellipsoidGeodesic . setEndPoints ( startCartographic , endCartographic ) ;
430
430
interpolateAndGrowRectangle ( ellipsoidGeodesic , inverseChordLength , result , idlCross ) ;
431
431
432
- if ( result . east - result . west > idlCross . west - idlCross . east ) {
433
- result . east = idlCross . east ;
434
- result . west = idlCross . west ;
432
+ if ( result . east - result . west > idlCross . eastOverIDL - idlCross . westOverIDL ) {
433
+ result . west = idlCross . westOverIDL ;
434
+ result . east = idlCross . eastOverIDL ;
435
+
436
+ if ( result . east > CesiumMath . PI ) {
437
+ result . east = result . east - CesiumMath . TWO_PI ;
438
+ }
439
+ if ( result . west > CesiumMath . PI ) {
440
+ result . west = result . west - CesiumMath . TWO_PI ;
441
+ }
435
442
}
436
443
437
444
return result ;
@@ -456,8 +463,9 @@ define([
456
463
result . south = Math . min ( result . south , latitude ) ;
457
464
result . north = Math . max ( result . north , latitude ) ;
458
465
459
- idlCross . west = longitude > 0.0 ? Math . min ( longitude , idlCross . west ) : idlCross . west ;
460
- idlCross . east = longitude < 0.0 ? Math . max ( longitude , idlCross . east ) : idlCross . east ;
466
+ var lonAdjusted = longitude >= 0 ? longitude : longitude + CesiumMath . TWO_PI ;
467
+ idlCross . westOverIDL = Math . min ( idlCross . westOverIDL , lonAdjusted ) ;
468
+ idlCross . eastOverIDL = Math . max ( idlCross . eastOverIDL , lonAdjusted ) ;
461
469
}
462
470
}
463
471
0 commit comments