Skip to content

Commit

Permalink
Merge pull request #1046 from xiongjiabin/master
Browse files Browse the repository at this point in the history
fix bug when the number of segments is integer(line-chunk)
  • Loading branch information
DenisCarriere authored Oct 27, 2017
2 parents c4e9dba + 55137ce commit cb92232
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/turf-line-chunk/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ function sliceLineSegments(line, segmentLength, units, callback) {
// If the line is shorter than the segment length then the orginal line is returned.
if (lineLength <= segmentLength) return callback(line);

var numberOfSegments = Math.floor(lineLength / segmentLength) + 1;
var numberOfSegments = lineLength / segmentLength;

// If numberOfSegments is integer, no need to plus 1
if (!Number.isInteger(numberOfSegments)) {
numberOfSegments = Math.floor(numberOfSegments) + 1;
}

for (var i = 0; i < numberOfSegments; i++) {
var outline = lineSliceAlong(line, segmentLength * i, segmentLength * (i + 1), {units: units});
callback(outline, i);
Expand Down

0 comments on commit cb92232

Please sign in to comment.