Turfjs / turf-buffer

Buffers a point, linestring, or polygon Feature/FeatureCollection to a given radius. Units supported are miles, kilometers, and degrees.
MIT License
22 stars 27 forks source link

Unable to Buffer on FeatureCollection of MultiPolygons #22

Open alukach opened 9 years ago

alukach commented 9 years ago

When trying to buffer on a FeatureCollection of MultiPolygons(this file), the current Buffer code (turf-buffer v1.0.1 used by turf v2.0.2) prepares the data by running it through combine. If the FeatureCollection's first feature's geometry type (fc.features[0].geometry.type) is "MultiPolygon", no geometry property is appended to the FeatureCollection during the combine operation. When the bufferOp later passes a stringified version of feature.geometry (which is undefined) to an instance of jsts.io.GeoJSONReader, the error Uncaught TypeError: Cannot read property 'type' of undefined is thrown. Based on my reading of the GeoJSON Feature Collection Objects spec, it is not invalid for a FeatureCollection object to not have a geometry property on the root of the object.

This bug appears to have been fixed with this committed change, so this issue can likely be tagged wont fix. I'm more interested in created this issue so that:

  1. It can be logged as a known issue for users of turf v2.0.2 and any other turf versions relying on turf-buffer v.1.0.1.
  2. Propose that a subset of that test file make it's way into a test fixture (likely within turf-combine)
  3. Enquire as to when turf-buffer >v1.0.1 (the repo appears to be at v1.0.4 at this moment) will be rolled into a main version of turf.
morganherlocker commented 9 years ago

@alukach I added your data as a test fixture https://github.com/Turfjs/turf-buffer/commit/2ce85b201d6e2f1f512123818763e387cc8b7118

I will get a new turf version rolled out next week and close this issue then. Thanks!

MichaelMarkieta commented 9 years ago

Any progress>?

k-mahoney commented 8 years ago

Ran into this issue, any further progress getting the fix incorporated into turf?