Skip to content

In JTSTriangulator, use DelaunayTriangulationBuilder instead of ConformingDelaunayTriangulator - #3128

Merged
michaz merged 1 commit into
graphhopper:masterfrom
james-willis:triangulator-builder
Feb 27, 2025
Merged

michaz merged 1 commit into
graphhopper:masterfrom
james-willis:triangulator-builder

Conversation

@james-willis

Copy link
Copy Markdown
Contributor

This PR is based on this discussion with Martin (Dr. JTS): locationtech/jts#1121

He suggested that DelaunayTriangulationBuilder is likely the most appropriate way to build this triangulation.

i'm unsure if there are other simplifications that can be made to this class based on the changes in this PR.

I apologize for failing to add a new test, I am struggling to build a test case that captures the bug in the JTS issue above.

@karussell

Copy link
Copy Markdown
Member

Thanks!

Did you test if there are any speed differences? And why is triangulationBuilder.getSubdivision() called twice?

I apologize for failing to add a new test

Unfortunately without this it will be harder to accept this PR.

@james-willis

Copy link
Copy Markdown
Contributor Author

why is triangulationBuilder.getSubdivision() called twice?

Fixed, it was not intentional.

Did you test if there are any speed differences?

The new version seems to be substantially faster.

I have an isochrone generation test that generates a 4 hour isochrone from some point in modesto with california-latest.osm.pbf from a few weeks ago. With the old implementation, it takes 5m 15s. With the new implementation it takes 1m 54s. I ran the test a few times to confirm.

Unfortunately without this it will be harder to accept this PR.

I will think about how I can write a good test to reproduce the stability issue.

@karussell karussell added this to the 11.0 milestone Feb 26, 2025
@james-willis

Copy link
Copy Markdown
Contributor Author

I wrote a test but it doesn't trigger the triangulation error in master.

Unfortunately I don't have more time to dedicate to this PR.

Test can be found in this branch: https://github.com/james-willis/graphhopper/tree/triangulator-builder-with-test.

I can add to this PR if you would like

@easbar

easbar commented Feb 26, 2025

Copy link
Copy Markdown
Member

What do you mean the test doesn't trigger the triangulation error in master. Does it trigger the error somewhere else?

@james-willis

Copy link
Copy Markdown
Contributor Author

What do you mean the test doesn't trigger the triangulation error in master. Does it trigger the error somewhere else?

I mean the test doesn't test the bug I've fixed with this PR. Fairly worthless.

@easbar

easbar commented Feb 26, 2025

Copy link
Copy Markdown
Member

Ok, but you are saying if we generate lots of isochrones like you explained in locationtech/jts#1121 the error should be triggered? Or is there something special we need to do to reproduce it?

@james-willis

james-willis commented Feb 26, 2025 •

Copy link
Copy Markdown
Contributor Author

I'm not sure if there is some characteristic of the graph (not OSM derived) I'm generating Isochrones from in that issue report that causes the bug to trigger. So I'm unsure if just generating a lot of isochrones will be sufficient to trigger the bug.

I think the test code I wrote could be used if we find a good case to repro with. I might be able to come back to this next week and see if I can fit the case from the issue above into the unit test in the linked branch.

@easbar

easbar commented Feb 26, 2025

Copy link
Copy Markdown
Member

Ok thanks. If you can come up with any instructions how to reproduce the error I can help extracting a unit test from it.

@michaz
michaz self-requested a review February 27, 2025 19:20

@michaz michaz left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Extremely good catch, many thanks!

Background: I ultimately do want to use ConformingDelaunayTriangulator, because I want to set the entire road network as constraints. Because that works, and it solves some problems that still exist. I verified that with a different, non-Java, implementation. However, I couldn't do that with this class, because I ran into issues with stability and performance.

What I missed was that some issues are still there if I don't set any constraints. Apparently I just took for granted that the class would behave the same as the regular one if the constraint set is empty.

If your feedback to Dr. JTS now means that someday we will be able to actually do the constrained triangulation, I will be up in the clouds.

@michaz
michaz merged commit 8072aee into graphhopper:master Feb 27, 2025
@michaz

michaz commented Feb 27, 2025

Copy link
Copy Markdown
Member

I mean...

@michaz

michaz commented Feb 27, 2025 •

Copy link
Copy Markdown
Member

There is also ConformingDelaunayTriangulationBuilder. I'm not sure if I ever tried that.

Maybe not.

By analogy, it might finally work if we use it.

@james-willis

Copy link
Copy Markdown
Contributor Author

There is also ConformingDelaunayTriangulationBuilder. I'm not sure if I ever tried that.

Yeah Dr JTS recommended this until he noticed we had no constraints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants