Turfjs / Turfjs/turf

lineSplit does not split horizontal lines that have more than 7 decimals in latitude

Open
#2,040 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

@turf/line-split
Dominant language
TypeScript
Stars
10.5k
Forks
1k
Avg merge
1h 11m
Merged PRs (30d)
4

Description

Turf Version: 6.3.0

lineSplit does not split horizontal lines whose latitudes have more than 7 decimal places.

For example, the test below fails

test("turf-line-split -- splitting horizontal lines with more than 7 lat decimals", (t) => {
  const x1 = 0
  const x2 = 10;
  const y = 0.12345678;

  const xMid = (x1 + x2)/2;

  const line = lineString([[x1, y], [x2, y]]);
  const splitter = point([xMid, y]);

  const { features } = lineSplit(line, splitter);

  // these fail; real result is an un-split line: lineString([ [ x1, y ], [ x2, y] ])
  t.isEqual(features.length, 2)
  t.deepEquals(features[0], lineString([[x1, y], [xMid, y]]));
  t.deepEquals(features[1], lineString([[xMid, y], [x2, y]]));

  t.end();
})

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the lineSplit entry point and reproduce the supplied horizontal-line case with latitude 0.12345678. Add the regression test shown in the issue, then verify that the line is split into two expected features and that the existing lineSplit tests still pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.