-
Notifications
You must be signed in to change notification settings - Fork 981
Support (Multi)Point,FeatureCollection and GeometryCollection in bboxClip #2814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
a607e77
5de593f
f4490cc
6a05a9f
0ff7cf7
3c91ee1
52a08d8
001a56e
ffd571a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,4 +33,4 @@ node_modules | |
|
||
.vscode | ||
|
||
.nx/ | ||
.nx/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,14 @@ | |
|
||
## bboxClip | ||
|
||
Takes a [Feature][1] and a bbox and clips the feature to the bbox using | ||
[lineclip][2]. | ||
May result in degenerate edges when clipping Polygons. | ||
Takes a [Feature][1], [Geometry][2] or [FeatureCollection][3] and a bbox and returns the part of the object within the bbox. | ||
Lines and polygons are clipped using [lineclip][4]. | ||
If a Point or LineString geometry is entirely outside the bbox, a [MultiPoint][5] or [MultiLineString][6] with empty `coordinates` array is returned. | ||
LineString geometries may also become MultiLineString if the clipping process cuts them into several pieces. | ||
Comment on lines
+7
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did we get to a point where we have a complete description of what might go in and what might go out? Is there something we can say here about polygons too? For example, If the input geometry is entirely outside the bbox a corresponding multi-geometry is returned with an empty coordinates array. Similarly, if a geometry is split into multiple pieces a corresponding multi-geometry is returned. If a multi-geometry is split and only a single item remains, the corresponding singular-geometry is returned. Probably don't need to quote the particular lineclip library. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's just the status quo. As for the rest, I really don't remember at this point. Whatever you decide is fine with me. |
||
|
||
### Parameters | ||
|
||
* `feature` **[Feature][1]<([LineString][3] | [MultiLineString][4] | [Polygon][5] | [MultiPolygon][6])>** feature to clip to the bbox | ||
* `feature` **([Geometry][2] | [Feature][1] | [FeatureCollection][3])** GeoJSON object to clip to the bbox | ||
* `bbox` **[BBox][7]** extent in \[minX, minY, maxX, maxY] order | ||
|
||
### Examples | ||
|
@@ -25,19 +26,19 @@ var clipped = turf.bboxClip(poly, bbox); | |
var addToMap = [bbox, poly, clipped] | ||
``` | ||
|
||
Returns **[Feature][1]<([LineString][3] | [MultiLineString][4] | [Polygon][5] | [MultiPolygon][6])>** clipped Feature | ||
Returns **([Feature][1] | [FeatureCollection][3])** clipped GeoJSON object. | ||
|
||
[1]: https://tools.ietf.org/html/rfc7946#section-3.2 | ||
|
||
[2]: https://github.com/mapbox/lineclip | ||
[2]: https://tools.ietf.org/html/rfc7946#section-3.1 | ||
|
||
[3]: https://tools.ietf.org/html/rfc7946#section-3.1.4 | ||
[3]: https://tools.ietf.org/html/rfc7946#section-3.3 | ||
|
||
[4]: https://tools.ietf.org/html/rfc7946#section-3.1.5 | ||
[4]: https://github.com/mapbox/lineclip | ||
|
||
[5]: https://tools.ietf.org/html/rfc7946#section-3.1.6 | ||
[5]: https://tools.ietf.org/html/rfc7946#section-3.1.3 | ||
|
||
[6]: https://tools.ietf.org/html/rfc7946#section-3.1.7 | ||
[6]: https://tools.ietf.org/html/rfc7946#section-3.1.5 | ||
|
||
[7]: https://tools.ietf.org/html/rfc7946#section-5 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
{ | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"coordinates": [92.78854443123498, -4.0631420171898185], | ||
"type": "Point" | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"coordinates": [88.80200582619335, -8.780228029258652], | ||
"type": "Point" | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"coordinates": [ | ||
[84.45578448719408, -0.42584674848238535], | ||
[104.00625645806042, -17.30113187521333], | ||
[108.37396514395846, -11.998337187512362] | ||
], | ||
"type": "LineString" | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"coordinates": [ | ||
[ | ||
[95.6755173613135, -5.412355325867296], | ||
[95.6755173613135, -9.59572648513172], | ||
[101.64270834459677, -9.59572648513172], | ||
[101.64270834459677, -5.412355325867296], | ||
[95.6755173613135, -5.412355325867296] | ||
] | ||
], | ||
"type": "Polygon" | ||
} | ||
}, | ||
|
||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"coordinates": [ | ||
[77.58616268346043, -7.556977393000622], | ||
[92.76209967554053, -19.675822211591438], | ||
[84.86920130192482, -25.38820065310992] | ||
], | ||
"type": "LineString" | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"coordinates": [ | ||
[ | ||
[84.5161586806538, 10.150704513809302], | ||
[84.5161586806538, 3.6873648155754495], | ||
[93.5370745092431, 3.6873648155754495], | ||
[93.5370745092431, 10.150704513809302], | ||
[84.5161586806538, 10.150704513809302] | ||
] | ||
], | ||
"type": "Polygon" | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"coordinates": [ | ||
[ | ||
[91.0644737234989, -0.5254035861065773], | ||
[91.0644737234989, -15.195974906738272], | ||
[98.81078524424902, -15.195974906738272], | ||
[98.81078524424902, -0.5254035861065773], | ||
[91.0644737234989, -0.5254035861065773] | ||
] | ||
], | ||
"type": "Polygon" | ||
} | ||
} | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this an intentional commit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a mistake. Feel free to correct it.