File tree Expand file tree Collapse file tree 3 files changed +29
-2
lines changed
Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 1414- [ ` @turf/union ` ] ( union ) Accept FeatureCollection for multiple inputs (#2247 )
1515- [ ` @turf/difference ` ] ( difference ) Accept FeatureCollection for multiple inputs (#2247 )
1616- [ ` @turf/intersect ` ] ( intersect ) Accept FeatureCollection for multiple inputs (#2247 )
17+ - [ ` @turf/buffer ` ] ( buffer ) Add undefined return for when the geometry is invalid (#2613 )
1718
1819## 🏅 New Features/Enhancements
1920- [ ` @turf/kinks ` ] ( kinks ) Move to sweepline-intersections library for performance (#1896 )
Original file line number Diff line number Diff line change @@ -31,12 +31,12 @@ declare function buffer(
3131 | MultiPolygon ,
3232 radius ?: number ,
3333 options ?: Options
34- ) : Feature < Polygon | MultiPolygon > ;
34+ ) : Feature < Polygon | MultiPolygon > | undefined ;
3535declare function buffer (
3636 feature : FeatureCollection < GeometryObject > | GeometryCollection ,
3737 radius ?: number ,
3838 options ?: Options
39- ) : FeatureCollection < Polygon | MultiPolygon > ;
39+ ) : FeatureCollection < Polygon | MultiPolygon > | undefined ;
4040
4141export { buffer } ;
4242export default buffer ;
Original file line number Diff line number Diff line change @@ -156,6 +156,32 @@ test("turf-buffer - morphological closing", (t) => {
156156 t . end ( ) ;
157157} ) ;
158158
159+ test ( "turf-buffer - undefined return" , ( t ) => {
160+ const poly : GeoJSON . Feature < GeoJSON . Polygon > = {
161+ type : "Feature" ,
162+ properties : { } ,
163+ geometry : {
164+ type : "Polygon" ,
165+ coordinates : [
166+ [
167+ [ - 101.87842323574378 , 52.250446362382775 ] ,
168+ [ - 101.87842323574378 , 49.56446202085259 ] ,
169+ [ - 98.29404114999511 , 49.56446202085259 ] ,
170+ [ - 98.29404114999511 , 52.250446362382775 ] ,
171+ [ - 101.87842323574378 , 52.250446362382775 ] ,
172+ ] ,
173+ ] ,
174+ } ,
175+ } ;
176+
177+ t . equal (
178+ buffer ( poly , - 100000000 ) ,
179+ undefined ,
180+ "empty geometry should be undefined if the resulting geometry is invalid"
181+ ) ;
182+ t . end ( ) ;
183+ } ) ;
184+
159185function colorize ( feature , color ) {
160186 color = color || "#F00" ;
161187 if ( feature . properties ) {
You can’t perform that action at this time.
0 commit comments