Turfjs / Turfjs/turf

LineOffset is crashing with two identical coordinates in sequence

Open
#1,946 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I'm getting the error:

catch, Error: coordinates must contain numbers

when there are two or more identical coordinates in sequence:

          const arr1 = [[1,1], [1,1]]
          const x = lineString(arr1)
          const y = lineOffset(x, 0.001)

but this works:

          const arr1 = [[1,1],[12,12], [1,1]]
          const x = lineString(arr1)
          const y = lineOffset(x, 0.001)

It isn't mentioned in the docs that it's not ok to have identical points...

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 by reproducing the issue through the lineString and lineOffset entry points with consecutive identical coordinates, then compare it with the working non-consecutive example. Done means lineOffset no longer crashes for the reported input, with behavior for duplicate points clarified or covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.