-
Notifications
You must be signed in to change notification settings - Fork 949
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
Initial commit turf buffer no jsts #876
Conversation
I'm good if we start adding Would look something like this: /**
* @param {Object} [options={}] Optional params
* @param {string} [options.units="kilometers"] can be degrees, radians, miles, kilometers, inches, yards, meters
* @param {number} [options.steps=64] number of steps on a rounded corner
*/
module.exports = function (feature, distance, options) {
options = options || {};
var units = options.units;
var steps = options.steps; @stebogit @rowanwins Feel free to look back at some previous modules and we can make a list of modules that would need this type of refactoring (modules with 2 or greater optional params) |
Yes! Something that would avoid this, quite used: var coords = getCoords(geojson);
switch (type) {
case 'LineString':
// do stuff with line coords
break;
case 'MultiLineString':
case 'Polygon':
// do stuff with lines or polygons coords
break;
case 'MultiPolygon':
coords.forEach(function (polygons) {
// do stuff with polygons coords
// add to result array of polygons
});
break;
case 'Point':
// do stuff with point coord
case 'MultiPoint':
// do stuff with points coord
break;
default:
throw new Error(type + ' geometry not supported');
}
Love this! |
👍 That would be pretty cool! We could maybe add this to
|
@rowanwins not that I'm giving hope... but there's no way we should be implementing this Buffer module internally, this seems like a massive undertaking. @rowanwins You can use this branch as "play" to help learn about Buffer operations, but I doubt this will ever get stable enough to release. One good take away from this would be to learn what is missing as smaller internal modules, such as |
🤔 Seems like this should be done internally, or at least an option in the param.
👍 Agreed, we need a solid projection module, still haven't cracked that one yet, I'm sure we can come up with a good solution using one of |
We should start using The JSDocs will look something like this: /**
* Takes a {@link Feature and returns a {@link Feature} at offset by the specified distance.
*
* @name buffer
* @param {Geometry|Feature<LineString>} geojson input
* @param {number} distance distance to buffer the feature (can be of negative value)
* @param {Object} [options={}] Optional parameters
* @param {string} [options.units=kilometers] can be degrees, radians, miles, kilometers, inches, yards, meters
* @param {number} [options.steps] Number of steps
* @returns {Feature} Feature buffered from the input feature
*/
module.exports = function (geojson, distance, options) { |
ye of little faith @DenisCarriere :) Yep it's a big job but having said that I've got the following working
Haven't tackled multipart or polygons with holes but they both should be relatively simple. Performance is currently beating jsts hands down. And I've made a start on catering for different join types and end types. So as far as Im concerned it's coming along it, it's just taking time, and if we don't do it who will? |
Just to prove some progress @DenisCarriere :) Current benchmarks
|
lol! 😆 I have faith! I'm just glad you are taking on this challenge, I'm going to test the 💩 out of it!
Awesome! 🎉
Those benchmark results are looking pretty decent! |
@@ -1,17 +1,28 @@ | |||
<<<<<<< HEAD |
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.
@rowanwins Looks like you've got a booboo 🤕 here
@DenisCarriere this might be totally unrelated but... What's the use of the It's not used at all, as seen in https://github.com/Turfjs/turf/blob/master/packages/turf-buffer/index.js#L81 |
Hi @amenadiel Steps to used to define how many vertices are used on rounded corners are on the buffer outputs. Eg setting steps to 3 will mean there are 3 vertices on a corner so you'll have a very jagged buffer, having it set at 64 gives nice smooth rounded corners. |
@rowanwins that's what it's meant to do. However, looking at the code it seems it's currently not used. It seems your PR adds support for real steps manipulation tho 👍 |
@rowanwins Going to close this PR, but I won't delete the branch for archive purposes (until we completely revamp |
Alright @DenisCarriere @stebogit
Here is a pretty rough commit of a dependency free buffer module
Positives
Needs work
Areas for thought
Lots more work required but thought I'd throw it up while I had time.