mapbox / mapbox/lineclip

Polygon Returning Incorrect Result

Open
#6 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
184
Forks
23
PR merge metrics
No merged PRs in 30d

Description

For this test case polygon() seems to return an incorrect result:

// Bounding box var bbp = [-123.5006568260586, -268.5301901840667, -113.19703085688374, -261.59299895444263]; // Test polygon var poly = [ [-127.7861230010377, -316.24149777631044], [-116.70896693414316, -294.6055724833417], [-112.85776301568613, -270.41743161420106], [-108.94104548638926, -246.3102843974042], [-113.9284569854127, -222.40054013470888], [-100.48054530104075, -224.3864178730988], [-95.49313380201731, -248.2961621357941], [-99.40985133131419, -272.40330935259095], [-103.26105524977122, -296.5914502217316], [-114.33821131666575, -318.2273755147003] ]; let t1 = lineclip.polyclip(poly, bb); // t1 = [[-113.19703085688374, -268.5301901840667], [-113.19703085688374, -261.59299895444263], [-113.19703085688374, -261.59299895444263], [-113.19703085688374, -268.5301901840667]];
Note that the x coordinate of the intersection box is exactly xmax. It looks to me like the polygon hits the bounding box in exactly the upper right corner. I think that case should return no intersection or just the point intersection, but what actually gets returned is the entire right side of the bounding box.

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 supplied polygon and bounding-box case through lineclip.polyclip, using the coordinates in the issue. Compare the returned right edge with the stated expected point or no-intersection behavior; done means the exact-corner case no longer returns the entire box side.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.