locationtech / jts

The JTS Topology Suite is a Java library for creating and manipulating vector geometry.
Other
1.94k stars 442 forks source link

Allow VariableBuffer to take in BufferParameters? #992

Open WindingWinter opened 1 year ago

WindingWinter commented 1 year ago

Similar to Buffer, I think VariableBuffer should also be able to take in BufferParameters as an argument.

This is because I want to use one side buffering for VariableBuffer also. The method Buffer(Geometry, Double[]) would be an ideal extension to take in the BufferParameters

dr-jts commented 1 year ago

Unfortunately VariableBuffer uses a different technique than the Buffer algorithm, and it is not obvious how to adapt it to produce single-sided buffer output.

WindingWinter commented 1 year ago

What if I only want to buffer polygons on one side, but not on the other? Will that simplify the problem? We ignore other considerations like whether the end sections should be mitered or not.

if it's not doable from within the engine, how about we manually process it from the outside:

  1. Buffer the polygon via variable buffer
  2. Extend the original (poly)line so that it cuts through the buffered polygon at two points.
  3. Traverse the two cut points, from the start to the end, and we can already form a close polygon that is buffered at only one side

Is this algorithm sound? It seems too simple, too good to be true.

On Thu, Jul 20, 2023 at 10:26 AM Martin Davis @.***> wrote:

Unfortunately VariableBuffer uses a different technique than the Buffer algorithm, and it is not obvious how to adapt it to produce single-sided buffer output.

— Reply to this email directly, view it on GitHub https://github.com/locationtech/jts/issues/992#issuecomment-1643011155, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADENIZRPQTHM26I7IIJPN4LXRCJLVANCNFSM6AAAAAA2QXSWCQ . You are receiving this because you authored the thread.Message ID: @.***>

dr-jts commented 1 year ago

What if I only want to buffer polygons on one side, but not on the other?

For buffering polygons, can you simply compute the difference (or intersection) of the polygon and the buffer to get the outside (or inside) buffer?

WindingWinter commented 1 year ago

I'm not too sure what you mean. What is "the polygon" ( the first one) referring to? Initially I only have a polyline, and I blow it up ( on both sides) to make it into a buffered polygon. There is no another polygon that I can use to perform the difference ( or intersection) operation with.

On Thu, Jul 20, 2023 at 10:42 AM Martin Davis @.***> wrote:

What if I only want to buffer polygons on one side, but not on the other?

For buffering polygons, can you simply compute the difference (or intersection) of the polygon and the buffer to get the outside (or inside) buffer?

— Reply to this email directly, view it on GitHub https://github.com/locationtech/jts/issues/992#issuecomment-1643022026, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADENIZUIOIBRR7HQH4JYO7LXRCLJJANCNFSM6AAAAAA2QXSWCQ . You are receiving this because you authored the thread.Message ID: @.***>

dr-jts commented 1 year ago

Oh, I see, you were talking about buffering a line. In that case, your technique will work, as long as the line doesn't self-intersect too much, and the endpoints are not too close to the rest of the line. So for many cases, this will work, but it's not a fully general solution.