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

Port JTS #448 #206

Closed
wants to merge 10 commits into from
Closed

Port JTS #448 #206

wants to merge 10 commits into from

Conversation

pramsey
Copy link
Member

@pramsey pramsey commented Jul 24, 2019

Fix Voronoi polygon generation by adding robust Triangle circumcentreDD

@dbaston
Copy link
Member

dbaston commented Jul 25, 2019

Adds a ~40% performance penalty in my quick test (bin/perf_voronoi). I wonder if the DD circumcenter can be used only when needed?

@dr-jts
Copy link
Contributor

dr-jts commented Jul 25, 2019

Adds a ~40% performance penalty in my quick test (bin/perf_voronoi). I wonder if the DD circumcenter can be used only when needed?

A few possibilities come to mind:

  • I think the robust circumcentre code is only need for Delaunay triangles which are right isosceles triangles. So perhaps a filter can be created to detect this condition (up to a tolerance) and fall back to the double-precision calc if not.
  • alternatively, detect when the circumcentre lies "close" to a triangle edge and if so recompute with higher precision
  • perhaps some inspection/experimentation with the circumcentre calculation would reveal a way of creating a filter based on intermediate values during the computation (e.g. if the denom is very large or the numx and numy are very close)
  • maybe very close Delaunay triangle circumcentres could be detected and snapped together. This could perhaps be done by processing each triangle after circumcentre calculation, and comparing centres of each adjacent triangle. Alternatively, if close circumcentres are found then recalculate using high precision.

So lots of options to try!

…cumcenter, namely that we have a potential equally-sided right triangle on our hands.
@pramsey
Copy link
Member Author

pramsey commented Jul 25, 2019

@dbaston see if the little pre-filter condition I've added takes some of the pain away

@dbaston
Copy link
Member

dbaston commented Jul 26, 2019

@dbaston see if the little pre-filter condition I've added takes some of the pain away

Yep, performance looks the same as master now. Thanks!

@pramsey
Copy link
Member Author

pramsey commented Jul 26, 2019

Pushed to master

@pramsey pramsey closed this Jul 26, 2019
@pramsey pramsey deleted the jts-448 branch September 13, 2019 18:25
@@ -421,7 +421,10 @@ class
Triangle triangle(triEdges[0]->orig().getCoordinate(),
triEdges[1]->orig().getCoordinate(), triEdges[2]->orig().getCoordinate());
Coordinate cc;
triangle.circumcentre(cc);
if (triangle.isIsoceles())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pramsey It looks like this heuristic doesn't work (mea culpa, since it was my suggestion). We should remove it, I think.

const char* expected =
"GEOMETRYCOLLECTION EMPTY";

runVoronoi(wkt, expected, 100);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tolerance here should be much smaller for this test to actually work. Say 0.1, or even 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants