Skip to content

Commit

Permalink
Merge pull request #886 from uq-eresearch/fix-bbox-clip-point-interse…
Browse files Browse the repository at this point in the history
…ction

Fix bbox-clip point intersection handling
  • Loading branch information
DenisCarriere authored Aug 3, 2017
2 parents 5c6eaa6 + 1d0a239 commit 5db975c
Show file tree
Hide file tree
Showing 3 changed files with 192 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/turf-bbox-clip/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ function clipPolygon(rings, bbox) {
if (clipped[0][0] !== clipped[clipped.length - 1][0] || clipped[0][1] !== clipped[clipped.length - 1][1]) {
clipped.push(clipped[0]);
}
outRings.push(clipped);
if (clipped.length >= 4) {
outRings.push(clipped);
}
}
}
return outRings;
Expand Down
83 changes: 83 additions & 0 deletions packages/turf-bbox-clip/test/in/polygon-point-intersection.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
115.872872384,
-31.977789227500004
],
[
115.87413347200001,
-31.978896027
],
[
115.874207392,
-31.978955634
],
[
115.874293312,
-31.978886666
],
[
115.875,
-31.9782948325
],
[
115.873511744,
-31.977027638
],
[
115.8731464,
-31.977071372
],
[
115.872185504,
-31.9771863865
],
[
115.872872384,
-31.977789227500004
]
]
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
115.875,
-31.98
],
[
115.880,
-31.98
],
[
115.880,
-31.975
],
[
115.875,
-31.975
],
[
115.875,
-31.98
]
]
]
}
}
]
}
106 changes: 106 additions & 0 deletions packages/turf-bbox-clip/test/out/polygon-point-intersection.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"stroke": "#080",
"fill": "#080",
"stroke-width": 6,
"fill-opacity": 0.1
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
115.872872384,
-31.977789227500004
],
[
115.87413347200001,
-31.978896027
],
[
115.874207392,
-31.978955634
],
[
115.874293312,
-31.978886666
],
[
115.875,
-31.9782948325
],
[
115.873511744,
-31.977027638
],
[
115.8731464,
-31.977071372
],
[
115.872185504,
-31.9771863865
],
[
115.872872384,
-31.977789227500004
]
]
]
}
},
{
"type": "Feature",
"properties": {
"stroke": "#F00",
"fill": "#F00",
"stroke-width": 6,
"fill-opacity": 0.1
},
"geometry": {
"type": "Polygon",
"coordinates": []
}
},
{
"type": "Feature",
"properties": {
"stroke": "#00F",
"fill": "#00F",
"stroke-width": 3,
"fill-opacity": 0.1
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
115.875,
-31.98
],
[
115.880,
-31.98
],
[
115.880,
-31.975
],
[
115.875,
-31.975
],
[
115.875,
-31.98
]
]
]
}
}
]
}

0 comments on commit 5db975c

Please sign in to comment.