Skip to content

Commit

Permalink
Bug fix for #78
Browse files Browse the repository at this point in the history
Simple logic error in choosing which coords to split on if multiple
intersections are detected for a segment and the segments already in the
sweep line tree.

Fixes #78
  • Loading branch information
mfogel committed Aug 15, 2019
1 parent f5ad4f2 commit e7ab60d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/sweep-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ export default class SweepLine {
else if (nextMySplitter === null) mySplitter = prevMySplitter
else {
const cmpSplitters = SweepEvent.comparePoints(prevMySplitter, nextMySplitter)
if (cmpSplitters < 0) mySplitter = prevMySplitter
if (cmpSplitters > 0) mySplitter = nextMySplitter
// the two splitters are the exact same point
mySplitter = prevMySplitter
mySplitter = cmpSplitters <= 0 ? prevMySplitter : nextMySplitter
}

// Rounding errors can cause changes in ordering,
Expand Down
36 changes: 36 additions & 0 deletions test/end-to-end/issue-78/args.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[-82.52799529864927, -143.1018307843396],
[-39.904413323673744, -30.14375420418703],
[82.49764582921772, -8.0378271183787],
[16.44517814188868, 28.188158503711254],
[-82.52799529864927, -143.1018307843396]
]
]
},
"properties": {}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[63.87786163053483, 190.5605341685717],
[-162.9109514965066, 149.5091687360925],
[-15.098334958220487, -25.754406771652196],
[63.87786163053483, 190.5605341685717]
]
]
},
"properties": {}
}
]
}
17 changes: 17 additions & 0 deletions test/end-to-end/issue-78/intersection.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[-15.16468395703966, -25.67573579594832],
[-15.098334958220487, -25.754406771652196],
[-15.062901059213404, -25.657353708804518],
[-15.16468395703966, -25.67573579594832]
]
]
]
}
}

0 comments on commit e7ab60d

Please sign in to comment.