@@ -748,20 +748,19 @@ export class FeatureTiles {
748748
749749 /**
750750 * Simplify x,y tile coordinates by 1 pixel
751- * @param lineString GeoJSON with coordinates in pixels
751+ * @param coordinatesArray GeoJSON with coordinates in pixels
752752 * @param isPolygon determines if the first and last point need to stay connected
753753 * @return simplified GeoJSON
754754 * @since 2.0.0
755755 */
756- simplifyPoints ( lineString : any , isPolygon = false ) : any | null {
757- lineString . coordinates = simplify (
758- lineString . coordinates . map ( coordinate => {
756+ simplifyPoints ( coordinatesArray : any , isPolygon = false ) : any | null {
757+ return simplify (
758+ coordinatesArray . map ( coordinate => {
759759 return { x : coordinate [ 0 ] , y : coordinate [ 1 ] } ;
760760 } ) ,
761761 this . simplifyToleranceInPixels ,
762762 false ,
763763 ) . map ( point => [ point . x , point . y ] ) ;
764- return lineString ;
765764 }
766765
767766 /**
@@ -773,18 +772,18 @@ export class FeatureTiles {
773772 * @param transform
774773 */
775774 getPath ( lineString : any , context : any , boundingBox : BoundingBox , isPolygon = false , transform : Function ) : void {
776- lineString . coordinates = lineString . coordinates . map ( coordinate => {
777- const transformedCoordinate = transform ( coordinate ) ;
775+ const line = lineString . coordinates . map ( coordinate => {
776+ const transformedCoordinate = transform ( coordinate . slice ( ) ) ;
778777 return [
779778 TileBoundingBoxUtils . getXPixel ( this . tileWidth , boundingBox , transformedCoordinate [ 0 ] ) ,
780779 TileBoundingBoxUtils . getYPixel ( this . tileHeight , boundingBox , transformedCoordinate [ 1 ] ) ,
781780 ] ;
782781 } ) ;
783- const simplifiedLineString = this . simplifyGeometries ? this . simplifyPoints ( lineString , isPolygon ) : lineString ;
784- if ( simplifiedLineString . coordinates . length > 1 ) {
785- context . moveTo ( simplifiedLineString . coordinates [ 0 ] [ 0 ] , simplifiedLineString . coordinates [ 0 ] [ 1 ] ) ;
786- for ( let i = 1 ; i < simplifiedLineString . coordinates . length ; i ++ ) {
787- context . lineTo ( simplifiedLineString . coordinates [ i ] [ 0 ] , simplifiedLineString . coordinates [ i ] [ 1 ] ) ;
782+ const simplifiedLineString = this . simplifyGeometries ? this . simplifyPoints ( line , isPolygon ) : line ;
783+ if ( simplifiedLineString . length > 1 ) {
784+ context . moveTo ( simplifiedLineString [ 0 ] [ 0 ] , simplifiedLineString [ 0 ] [ 1 ] ) ;
785+ for ( let i = 1 ; i < simplifiedLineString . length ; i ++ ) {
786+ context . lineTo ( simplifiedLineString [ i ] [ 0 ] , simplifiedLineString [ i ] [ 1 ] ) ;
788787 }
789788 }
790789 }
0 commit comments