Permalink
Browse files

Correct failing single sided buffer issue.

  • Loading branch information...
1 parent 2d618f6 commit b14a27eb4b689ee59fe21db96dc5164dc7e4697d @tschaub committed Sep 15, 2011
Showing with 5 additions and 9 deletions.
  1. +4 −8 lib/geoscript/geom/geometry.js
  2. +1 −1 tests/geoscript/geom/test_point.js
@@ -257,15 +257,11 @@ var Geometry = UTIL.extend(GeoObject, {
* Construct a geometry that buffers this geometry by the given width.
*/
buffer: function(dist, options) {
- options = UTIL.applyIf(options, {
- segs: 8,
- caps: GEOM_UTIL.BUFFER_CAP_ROUND,
- single: false
- });
+ options = options || {};
var params = new BufferParameters();
- params.setSingleSided(options.single);
- params.setQuadrantSegments(options.segs);
- params.setEndCapStyle(options.caps);
+ params.setSingleSided(!!options.single);
+ params.setQuadrantSegments(options.segs || 8);
+ params.setEndCapStyle(options.caps || GEOM_UTIL.BUFFER_CAP_ROUND);
var _geometry = this._geometry;
if (this.prepared) {
@@ -86,7 +86,7 @@ exports["test: buffer"] = function() {
ASSERT.ok(b instanceof GEOM.Polygon, "buffered point creates a polygon");
ASSERT.strictEqual(b.area.toFixed(2), "3.12", "almost PI");
- b = p.buffer(1, 24);
+ b = p.buffer(1, {segs: 24});
ASSERT.strictEqual(b.area.toFixed(2), "3.14", "more arc segments, higher accuracy");
};

0 comments on commit b14a27e

Please sign in to comment.