Turfjs / Turfjs/turf

add precision parameter to intersect to pass into polyclip-ts?

Open
#2,890 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I am facing the 'unable to complete output ring' from intersect that was discussed in #2048 - I am using 0.7.2 so I am using the polyclip-ts version of Turf, which was the preferred fix in 2048.

I think my issue is related to floating point accuracy - I get this error from polyclip:

Error: Unable to complete output ring starting at [-89.33422366666666666667, 43.09035333333333333333]. Last matching segment found ends at [-89.334221, 43.09036].

There's an issue in polyclip-ts - https://github.com/luizbarboza/polyclip-ts/issues/5 that suggests changing the precision that polyclip-ts uses - there's a call available in polyclip for polyclip.setPrecision()

If I replicate the turfjs intersect code but add a setPrecision call to something very high I no longer see the error and I get the expected result.

Would it be possible to add a parameter to turf-intersect for precision that it can pass along to polyclip?

(Happy to pass along the problematic polygons if that would help)

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 turf-intersect entry point and compare its polyclip-ts usage with the setPrecision call described in the issue. Review polyclip-ts issue #5 and the prior discussion in #2048, then determine how a precision parameter should be forwarded. Done means intersect accepts the parameter and the reported polygons complete without the output-ring error.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 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.