开发者

In JTS, when I do geometry.buffer(1).buffer(-1), will the resulting geometry be equivalent to the original?

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?


I don't know anything about JTS, but it can't be true in general.

Assume you have two shapes:

 XXX      XXX
 X X      XXX
 XXX      XXX

From my understanding a buffer(1) on both would result in roughly this:

XXXXX    XXXXX
XXXXX    XXXXX
XXXXX    XXXXX
XXXXX    XXXXX
XXXXX    XXXXX

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜