Skip to content
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

Voronoi diagram fails due to self-intersecting polygons #447

Closed
dr-jts opened this issue Jul 15, 2019 · 6 comments
Closed

Voronoi diagram fails due to self-intersecting polygons #447

dr-jts opened this issue Jul 15, 2019 · 6 comments

Comments

@dr-jts
Copy link
Contributor

dr-jts commented Jul 15, 2019

Voronoi diagram building fails on the following input, due to the fact that some of the input sites lie on a grid pattern, which causes some Voronoi polygon vertices to experience numerical precision errors.

0104000080170000000101000080EC51B81E11A20741EC51B81E85A51C415C8FC2F528DC354001010000801F85EB5114A207415C8FC2F585A51C417B14AE47E1BA3540010100008085EB51B818A20741A8C64B3786A51C413E0AD7A3709D35400101000080000000001BA20741FED478E984A51C413E0AD7A3709D3540010100008085EB51B818A20741FED478E984A51C413E0AD7A3709D354001010000800AD7A37016A20741FED478E984A51C413E0AD7A3709D35400101000080000000001BA2074154E3A59B83A51C413E0AD7A3709D3540010100008085EB51B818A2074154E3A59B83A51C413E0AD7A3709D354001010000800AD7A37016A2074154E3A59B83A51C413E0AD7A3709D35400101000080000000001BA20741AAF1D24D82A51C413E0AD7A3709D3540010100008085EB51B818A20741AAF1D24D82A51C413E0AD7A3709D35400101000080F6285C8F12A20741EC51B81E88A51C414160E5D022DB354001010000802222222210A2074152B81EC586A51C414160E5D022DB354001010000804F1BE8B40DA2074152B81EC586A51C414160E5D022DB354001010000807B14AE470BA2074152B81EC586A51C414160E5D022DB354001010000802222222210A20741B81E856B85A51C414160E5D022DB354001010000804F1BE8B40DA20741B81E856B85A51C414160E5D022DB354001010000807B14AE470BA20741B81E856B85A51C414160E5D022DB35400101000080A70D74DA08A20741B81E856B85A51C414160E5D022DB35400101000080D4063A6D06A20741B81E856B85A51C414160E5D022DB354001010000807B14AE470BA207411F85EB1184A51C414160E5D022DB35400101000080A70D74DA08A207411F85EB1184A51C414160E5D022DB35400101000080D4063A6D06A207411F85EB1184A51C414160E5D022DB3540

This is due to a couple of the generated Voronoi polygons being topologically invalid, and because of that failing during the intersection computation (when clipping the raw Voronoi polygons to a surrounding rectangle).

The reason the polygons are invalid is that they contain two points which are almost identical, one of which happens to lie on another edge of the polygon, thus creating a self-intersection.

The reason the very close points are present is because the input points (Voronoi sites) generating them lie on a regular grid pattern. This produces two Delaunay triangles with almost identical circumcentres. They are not 100% identical because of round-off error. The DT circumcentres form the vertices of the Voronoi polygons, and so polygons are created with almost-but-not-identical points in them.

Original report: https://trac.osgeo.org/geos/ticket/976

@dr-jts
Copy link
Contributor Author

dr-jts commented Jul 15, 2019

The raw generated Voronoi polygons (before clipping, which fails)

raw-voronoi-polygons

@dr-jts
Copy link
Contributor Author

dr-jts commented Jul 15, 2019

Some of the sites lying on a regular grid, with the Delaunay triangles. The circumcentres of the two right triangles should be identical, but are computed as very slightly different due to round-off.

sites-and-delaunay

@dr-jts
Copy link
Contributor Author

dr-jts commented Jul 15, 2019

The invalid generated Voronoi polygons.

invalid-voronoi-polygons

@dr-jts
Copy link
Contributor Author

dr-jts commented Jul 15, 2019

Detail of an invalid Voronoi polygon, showing almost-but-not-identical vertices causing self-intersection.

invalid-polygon-detail

@dr-jts
Copy link
Contributor Author

dr-jts commented Jul 15, 2019

A test case to reproduce the problem of slightly different triangle circumcentres:

GEOMETRYCOLLECTION (POLYGON ((193600.80333333334 469345.355, 193600.80333333334 469345.0175, 193601.10666666666 469345.0175, 193600.80333333334 469345.355)), 
  POLYGON ((193600.80333333334 469345.355, 193601.10666666666 469345.0175, 193601.10666666666 469345.355, 193600.80333333334 469345.355)))

The current JTS Triangle.circumcentre method produces this:

GEOMETRYCOLLECTION ( POINT (193600.95500000002 469345.18625), 
                     POINT (193600.95500000002 469345.18624999997) )

It might be possible to improve this using DD to perform the circumcentre computation.

@dr-jts
Copy link
Contributor Author

dr-jts commented Jul 16, 2019

Fixed by #448

@dr-jts dr-jts closed this as completed Jul 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant