8000 Fix VoronoiDiagramBuilder to respect clip envelope by dr-jts · Pull Request #740 · locationtech/jts · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix VoronoiDiagramBuilder to respect clip envelope #740

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

Merged
merged 1 commit into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,21 @@ private void create()
{
if (subdiv != null) return;

Envelope siteEnv = DelaunayTriangulationBuilder.envelope(siteCoords);
diagramEnv = clipEnv;
if (diagramEnv == null) {
/**
* If no user-provided clip env,
* create one which encloses all the sites,
* with a buffer around the edges.
* If no user-provided clip envelope,
* use one which encloses all the sites,
* with a 50% buffer around the edges.
*/
diagramEnv = siteEnv;
// add a buffer around the sites envelope
diagramEnv = DelaunayTriangulationBuilder.envelope(siteCoords);
// add a 50% buffer around the sites envelope
double expandBy = diagramEnv.getDiameter();
diagramEnv.expandBy(expandBy);
}

List vertices = DelaunayTriangulationBuilder.toVertices(siteCoords);
subdiv = new QuadEdgeSubdivision(siteEnv, tolerance);
subdiv = new QuadEdgeSubdivision(diagramEnv, tolerance);
IncrementalDelaunayTriangulator triangulator = new IncrementalDelaunayTriangulator(subdiv);
triangulator.insertSites(vertices);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ public void testClipEnvelope() {
assertTrue(voronoi.getEnvelopeInternal().equals(clip.getEnvelopeInternal()));
}

public void testClipEnvelopeBig() {
Geometry sites = read("MULTIPOINT ((50 100), (50 50), (100 50), (100 100))");
Geometry clip = read("POLYGON ((-1000 1000, 1000 1000, 1000 -1000, -1000 -1000, -1000 1000))");
Geometry voronoi = voronoiDiagram(sites, clip);
assertTrue(voronoi.getEnvelopeInternal().equals(clip.getEnvelopeInternal()));
}

private static final double TRIANGULATION_TOLERANCE = 0.0;

public static Geometry voronoiDiagram(Geometry sitesGeom, Geometry clipGeom)
Expand Down
0