在JTS中,当我执行geometry.buffer(1).buffer(-1)时,生成的几何图形是否等于原始几何图形?
我在相交两个几何图形时遇到问题,可能由于操作期间的舍入错误而出现 TopologyException,然后我读了 此修复 并在两个输入几何图形上尝试了 buffer(0)
,但仍然没有成功。然后我尝试了 geo.buffer(1).buffer(-1) 并成功了。
这些几何形状与原始几何形状相同吗?
I was having problems while intersecting two geometries, getting a TopologyException probably due to a rounding error during the operation, then I read this fix and tried a buffer(0)
on both input geometries, but still without success. Then I tried geo.buffer(1).buffer(-1)
and it worked.
Will these geometries be equivalent to the original ones?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我对JTS一无所知,但一般来说这不可能是真的。
假设你有两个形状:
根据我的理解,两个形状上的
buffer(1)
大致会导致这样的结果:现在
buffer(-1)
将无法产生两个这两种形状的结果不同。实际上,
buffer()
操作会丢失信息,因此如果不从其他地方重新添加该信息,就无法撤消该操作。I don't know anything about JTS, but it can't be true in general.
Assume you have two shapes:
From my understanding a
buffer(1)
on both would result in roughly this:Now
buffer(-1)
won't be able to produce two different results from those two shapes.Effectively a
buffer()
operation looses information, so it can't be undone without re-adding that information from somewhere else.我认为这些几何形状不会相同。默认情况下,缓冲要素的行为会将顶点添加到其原始配置中,并且不能保证相同的顶点将被删除。
尝试创建一个非常小的缓冲区,例如 a.buffer(0.00001)(如果坐标采用公制系统,则为 1/1000mm)。
在 PostGIS 中,一些问题可以通过这样做得到纠正。
I don't think these geometries will be the same. By default behavior buffering a feature add vertices to it's original configuration, and there is no guarantee that the same vertices will be removed.
Try doing a very small buffer, a.buffer(0.00001), for instance (1/1000th mm, if coordinates in metric systems).
In PostGIS some issues are corrected by doing this.