geometry difference precision

59 views
Skip to first unread message

Ahmed Mayo

unread,
Apr 15, 2018, 11:47:27 AM4/15/18
to JSTS devs
I want the user to be able two create polygons. The cannot intersect, but they may touch. I use the check like this
```
geom1
.intersects(geom2) && !geom1.touches(geom2) \\ if true, then the polygons are not valid
```

I also try to enable the user to remove the intersection and proceed

```
diffedGeom = geom1
.difference(geom2)
```

But, when I use the new geometry instead of the original, it does not pass the previous check.

After checking the area of the difference between the new geometry and the other I get this result
```
diffedGeom
.intersection(geom2).getArea() // 1.0056829085145967e-17
```

This is the image of the two polygons after diffing, this shows how small is the intersection


This small intersection is preventing the user from proceeding, because it never passes the check

example geometries created from these WKT polygons
geom1: POLYGON ((-3.922119140625 40.52423878069866,-3.7937164306640625 40.522150985623796,-3.7841033935546875 40.46993497635155,-3.8858892845517676 40.45336687859892,-3.876800537109375 40.49865881031931,-3.922119140625 40.490387150697316,-3.922119140625 40.52423878069866,-3.922119140625 40.52423878069866))
geom2: POLYGON ((-3.876800537109375 40.49865881031931,-3.890533447265625 40.430223634508614,-3.9626312255859375 40.43335959357837,-3.9626312255859375 40.48299278830796,-3.876800537109375 40.49865881031931))


Reply all
Reply to author
Forward
0 new messages