@@ -26,7 +26,7 @@ const TEMP_POINT0 = new Point(0, 0);
26
26
const TEMP_PAINT_EXTENT = new PointExtent ( ) ;
27
27
const TEMP_EXTENT = new PointExtent ( ) ;
28
28
const TEMP_FIXED_EXTENT = new PointExtent ( ) ;
29
- // const TEMP_CLIP_EXTENT0 = new PointExtent();
29
+ const TEMP_CLIP_EXTENT0 = new PointExtent ( ) ;
30
30
const TEMP_CLIP_EXTENT1 = new PointExtent ( ) ;
31
31
// const TEMP_CONTAINER_EXTENT = new PointExtent();
32
32
@@ -390,16 +390,25 @@ class Painter extends Class {
390
390
} ;
391
391
}
392
392
const glExtent2D = glExtent . _expand ( lineWidth * map . _glScale ) ;
393
+ const { xmin, ymin, xmax, ymax } = glExtent2D ;
394
+ const dx = Math . abs ( xmax - xmin ) , dy = Math . abs ( ymax - ymin ) ;
395
+ const maxEdge = Math . max ( dx , dy ) ;
396
+ const r = maxEdge / 2 ;
397
+ TEMP_CLIP_EXTENT0 . xmin = glExtent2D . xmin - r ;
398
+ TEMP_CLIP_EXTENT0 . xmax = glExtent2D . xmax + r ;
399
+ TEMP_CLIP_EXTENT0 . ymin = glExtent2D . ymin - r ;
400
+ TEMP_CLIP_EXTENT0 . ymax = glExtent2D . ymax + r ;
401
+
393
402
const smoothness = geometry . options [ 'smoothness' ] ;
394
403
// if (this.geometry instanceof Polygon) {
395
404
if ( geometry . getShell && this . geometry . getHoles && ! smoothness ) {
396
405
// clip the polygon to draw less and improve performance
397
406
if ( ! Array . isArray ( points [ 0 ] ) ) {
398
- clipPoints = clipPolygon ( points , glExtent2D ) ;
407
+ clipPoints = clipPolygon ( points , TEMP_CLIP_EXTENT0 ) ;
399
408
} else {
400
409
clipPoints = [ ] ;
401
410
for ( let i = 0 ; i < points . length ; i ++ ) {
402
- const part = clipPolygon ( points [ i ] , glExtent2D ) ;
411
+ const part = clipPolygon ( points [ i ] , TEMP_CLIP_EXTENT0 ) ;
403
412
if ( part . length ) {
404
413
clipPoints . push ( part ) ;
405
414
}
@@ -408,11 +417,11 @@ class Painter extends Class {
408
417
} else if ( geometry . getJSONType ( ) === 'LineString' && ! smoothness ) {
409
418
// clip the line string to draw less and improve performance
410
419
if ( ! Array . isArray ( points [ 0 ] ) ) {
411
- clipPoints = clipLine ( points , glExtent2D , false , ! ! smoothness ) ;
420
+ clipPoints = clipLine ( points , TEMP_CLIP_EXTENT0 , false , ! ! smoothness ) ;
412
421
} else {
413
422
clipPoints = [ ] ;
414
423
for ( let i = 0 ; i < points . length ; i ++ ) {
415
- pushIn ( clipPoints , clipLine ( points [ i ] , glExtent2D , false , ! ! smoothness ) ) ;
424
+ pushIn ( clipPoints , clipLine ( points [ i ] , TEMP_CLIP_EXTENT0 , false , ! ! smoothness ) ) ;
416
425
}
417
426
}
418
427
//interpolate line's segment's altitude if altitude is an array
0 commit comments