LineOffset does not respect distances...

Open
#2,278 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Domain
data

Research direction

Reproduce the example using turf.lineString and getLineOffset with ±4-meter units, then compare the oblique-segment coordinates with the shown buffer. Done means the returned left and right lines maintain the requested 4-meter offset for both horizontal and oblique segments, or the issue is narrowed to a documented limitation or alternative.

Written by the indexing model from the issue text.

Description

@turf/line-offset

Hi,

II read several posts on the subject but I did not really find the answer.
I have a line expressed with WGS84 coordinates:

let myline = turf.lineString([4.101441, 44.279814]
,[4.101386, 44.279732]
,[4.101333, 44.279696]
,[4.10132, 44.279696]
,[4.101225, 44.279696]
,[4.101051, 44.27973]
,[4.100738, 44.279791]
,[4.100121, 44.279911]
,[4.099466, 44.280038]
,[4.099459, 44.280039]
,[4.09937, 44.280057]);

let rightline = getLineOffset(myline , 4, {units: 'meters'});
let leftline = getLineOffset(myline , -4, {units: 'meters'});

Right coordinates returned :

[4.101411124977849, 44.27983403812462]
,[4.101360013256536, 44.279757835194665]
,[4.101321938085819, 44.27973197281455]
,[4.10132, 44.27973197281455]
,[4.101228481662364, 44.27973197281455]
,[4.101057889945491, 44.279765306828196]
,[4.100744874438115, 44.2798263098504]
,[4.100127857509158, 44.2799463131429]
,[4.099471971015376, 44.280073485027955]
,[4.099465114251917, 44.280074464565594]
,[4.099377131019004, 44.280092258927304]

Left coordinates returned :

[4.101470875022152, 44.279793961875384]
,[4.1014119867434635, 44.27970616480534]
,[4.1013440619141805, 44.27966002718545]
,[4.10132, 44.27966002718545]
,[4.101221518337637, 44.27966002718545]
,[4.101044110054509, 44.279694693171805]
,[4.100731125561884, 44.27975569014961]
,[4.100114142490841, 44.279875686857096]
,[4.099460028984623, 44.28000251497204]
,[4.099452885748069, 44.28000353543441]
,[4.099362868980997, 44.280021741072694]

As you can see in the following picture, the offset seams to be ok for horizontal segments, but wrong for oblique segments. (myline in blue, buffer of 4 meters around myline in red, left and right lines in black)

image
is this a bug or am i forgetting something ?

What is the alternative to circumvent the problem?

Thanks for your help

Dominant language
TypeScript
Stars
10.5k
Forks
1k
Avg merge
1h 11m
Merged PRs (30d)
4

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.

More from Turfjs/turf

All issues in Turfjs/turf

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.