locationtech / jts

The JTS Topology Suite is a Java library for creating and manipulating vector geometry.
Other
1.99k stars 443 forks source link

ClipEnvelope of Voronoi Diagram is not working fine #720

Closed narcismadern closed 3 years ago

narcismadern commented 3 years ago

According to documentation, the resulting Voronoi Diagram after calling method 'getDiagram(...)' is clipped using the Envelope defined within 'setClipEnvelope' method, if it's larger than the envelope defined by the points themselves.

I was expecting that the exterior faces of the Voronoi Diagram are "infinite" and then clipped by that envelope, but that is not true when the envelope defined by the user is larger than the envelope defined by the points the Voronoi is computed from.

For example, if I have these 2 points [-1, 0] [1, 0], and I define the clip envelope to be [-10,10] [10,-10], I expected to have a Voronoi Diagram containing two polygons [[0,-10] [-10,-10] [-10,10] [0,10]] and [[0,-10] [10,-10] [10,10] [0,10]], but instead, I get much smaller polygons, as if the clipping envelope was much smaller than the one I defined.

I believe the problem is within the class 'VoronoiDiagramBuilder', method 'create()', line 127:

image

No matter the content of 'diagramEnv' (either the envelope set by the user or the one created from the points if the former was not provided), the QuadEdgeSubdivision always uses 'siteEnv' which contains the envelope of the site coords returned at line 112.

I did not submit a change request because I don know the implications of changing this envelope when computing the QuadEdgeSubdivision, but I suspect that 'diagramEnv' needs to be used here rather than the current 'siteEnv'.

Could you please confirm this (in which case I can submit a change request) or instead tell me what I am doing / interpreting wrong?

Thanks in advance!

dr-jts commented 3 years ago

Yes, this is a bug. The diagramEnv should be passed to the QuadEdgeSubdivision constructor:

subdiv = new QuadEdgeSubdivision(diagramEnv, tolerance);

It would be great if you can submit a PR.

narcismadern commented 3 years ago

Hi Martin,

I'm having problems to push my changes. It seems I don't have permission to push or change anything in this repo. Maybe you can help me out understand what I need to set to be able to make modifications?

remote: Permission to locationtech/jts.git denied to narcismadern.
fatal: unable to access 'https://github.com/locationtech/jts.git/': The requested URL returned error: 403

Thanks!

FObermaier commented 3 years ago

@narcismadern you need to fork the repository, commit/push to that personal copy of this repository, and then create a pull request.

narcismadern commented 3 years ago

Pull Request: https://github.com/locationtech/jts/pull/724

dr-jts commented 3 years ago

Fixed by #740