diff --git a/src/geometry/Ellipse.js b/src/geometry/Ellipse.js index a8b1202d85..aa2943e97a 100644 --- a/src/geometry/Ellipse.js +++ b/src/geometry/Ellipse.js @@ -12,7 +12,7 @@ import Circle from './Circle'; * @instance */ const options = { - 'numberOfShellPoints': 80 + 'numberOfShellPoints': 81 }; /** @@ -102,7 +102,7 @@ class Ellipse extends CenterMixin(Polygon) { _getShell() { const measurer = this._getMeasurer(), center = this.getCoordinates(), - numberOfPoints = this.options['numberOfShellPoints'], + numberOfPoints = this.options['numberOfShellPoints'] - 1, width = this.getWidth(), height = this.getHeight(); const shell = []; @@ -125,6 +125,7 @@ class Ellipse extends CenterMixin(Polygon) { vertex.z = center.z; shell.push(vertex); } + shell.push(shell[0].copy()); return shell; } diff --git a/test/geometry/EllipseSpec.js b/test/geometry/EllipseSpec.js index b81b76febf..c11b3a67fe 100644 --- a/test/geometry/EllipseSpec.js +++ b/test/geometry/EllipseSpec.js @@ -77,9 +77,9 @@ describe('Geometry.Ellipse', function () { var ellipse = new maptalks.Ellipse([0, 0], 1000, 800); var shell = ellipse.getShell(); - var num = ellipse.options.numberOfShellPoints; - expect(shell).to.have.length(num); - var sumx = 0, sumy = 0, len = shell.length; + var num = ellipse.options.numberOfShellPoints - 1; + expect(shell).to.have.length(ellipse.options.numberOfShellPoints); + var sumx = 0, sumy = 0, len = shell.length - 1; for (var i = 0; i < len; i++) { sumx += shell[i].x; sumy += shell[i].y; @@ -96,9 +96,9 @@ describe('Geometry.Ellipse', function () { var ellipse = new maptalks.Ellipse([0, 0, 100], 1000, 800); var shell = ellipse.getShell(); - var num = ellipse.options.numberOfShellPoints; - expect(shell).to.have.length(num); - var sumx = 0, sumy = 0, len = shell.length; + var num = ellipse.options.numberOfShellPoints - 1; + expect(shell).to.have.length(ellipse.options.numberOfShellPoints); + var sumx = 0, sumy = 0, len = shell.length - 1; for (var i = 0; i < len; i++) { sumx += shell[i].x; sumy += shell[i].y;