static private double connectLon ( double connect , double val ) { if ( Double . isNaN ( connect ) ) return val ; if ( Double . isNaN ( val ) ) return val ; double diff = val - connect ; if ( Math . abs ( diff ) < MAX_JUMP ) return val ; // common case fast // we have to add or subtract 360 double result = diff > 0 ? val - 360 : val + 360 ; double diff2 = connect - result ; if ( ( Math . abs ( diff2 ) ) < Math . abs ( diff ) ) val = result ; return val ; }
larger than you would ever expect