Skip to content

Commit d21e658

Browse files
committed
Rolling back cloning workaround from commit d7c5322. This appears to have been unnecessary, possibly already having been fixed by adding linearRing: false to the isoContours call.
1 parent 9a25883 commit d21e658

File tree

3 files changed

+3
-432
lines changed

3 files changed

+3
-432
lines changed

packages/turf-isolines/index.ts

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import bbox from "@turf/bbox";
2-
import clone from "@turf/clone";
32
import { coordEach } from "@turf/meta";
43
import { collectionOf } from "@turf/invariant";
54
import { multiLineString, featureCollection, isObject } from "@turf/helpers";
@@ -157,35 +156,11 @@ function rescaleIsolines(
157156
point[1] = point[1] * scaleY + y0;
158157
};
159158

160-
// Ok. We need to *clone* the returned isolines due to the behaviour of
161-
// the marchingsquare library behaviour. Long story short, if we don't
162-
// do this, the last point in some isoLines has the coordEach function
163-
// run twice, leading to one point in the isoline rendering WAY out of
164-
// position.
165-
const clonedIsoLines: Feature<MultiLineString>[] = [];
166-
createdIsoLines.forEach((isoline) => {
167-
clonedIsoLines.push(clone(isoline));
168-
});
169-
170159
// resize and shift each point/line of the createdIsoLines
171-
clonedIsoLines.forEach((isoline) => {
160+
createdIsoLines.forEach((isoline) => {
172161
coordEach(isoline, resize);
173162
});
174-
return clonedIsoLines;
163+
return createdIsoLines;
175164
}
176165

177-
/*
178-
* A bit more background on the isoContours behaviour described above. It
179-
* seems like in some cases the last coord of the line references the same
180-
* coord array as the first point. This just seems to be the way they're
181-
* returned from the library:
182-
* [0] -> A
183-
* [1] -> B
184-
* [2] -> C
185-
* [3] -> A
186-
* Running coordEach over this mutates the values in A, then B and C, then
187-
* mutates [3] which happens to also be a reference to A. So the rescale
188-
* transform is run twice on that coord.
189-
*/
190-
191166
export default isolines;

0 commit comments

Comments
 (0)