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

Control Geometry overlay algorithm via system property #615

Merged
merged 5 commits into from
Oct 20, 2020

Conversation

dr-jts
Copy link
Contributor

@dr-jts dr-jts commented Oct 17, 2020

Control Geometry overlay algorithm via a system property jts-overlay. This makes it possible to use OverlayNG in existing deployments with no code changes.

@FObermaier
Copy link
Contributor

FObermaier commented Oct 17, 2020

I have a different proposal: Why don't we tie geometry operations/predicates to the GeometryFactory. The geometry would invoke the operation by passing itself and arguments to a function on the factory.
That way a factory that uses old Overlay code and one that uses OverlayNG code is easily doable,
plus one that calculates distances in meters or areas in square meters from lat-lon coordinates could be easyly added.

Signed-off-by: Martin Davis <mtnclimb@gmail.com>
Signed-off-by: Martin Davis <mtnclimb@gmail.com>
Signed-off-by: Martin Davis <mtnclimb@gmail.com>
@dr-jts
Copy link
Contributor Author

dr-jts commented Oct 19, 2020

I have a different proposal: Why don't we tie geometry operations/predicates to the GeometryFactory. The geometry would invoke the operation by passing itself and arguments to a function on the factory.
That way a factory that uses old Overlay code and one that uses OverlayNG code is easily doable,
plus one that calculates distances in meters or areas in square meters from lat-lon coordinates could be easyly added.

A good idea. We have had design discussions about JTS 2, and one of the ideas is to provide a geometry method registry concept, to support this kind of flexibility. The current concept is to make it static, so that it's easy to access from Geometry implementations (in JTS 2 Geometry will be an interface). But it could make sense to attach it to the GeometryFactory, since that is already injected into geometries.

Perhaps this would be done as a GeometryMethods interface, with a set of methods matching the Geometry methods (but taking an initial Geometry argument). It would be backed by a concrete class that could be overridden for individual methods.

That said, the goal of this small enhancement is to make it easy for current users of JTS to switch to using OverlayNG with no code changes. Thus I think the PR is reasonable as it stands. The implementation can be enhanced as and when there is clear demand for it.

@dr-jts
Copy link
Contributor Author

dr-jts commented Oct 19, 2020

I realized that this code should use OverlayNG with Snap-Rounding for geometries with a fixed precision model. Will add an enhancement for that.

And since this is starting to get complex, I will expose a method to set the overlayNG flag programmatically, to allow unit testing.

Signed-off-by: Martin Davis <mtnclimb@gmail.com>
Signed-off-by: Martin Davis <mtnclimb@gmail.com>
@dr-jts dr-jts merged commit 31cb7b6 into locationtech:master Oct 20, 2020
@dr-jts dr-jts deleted the add-overlay-switch branch October 20, 2020 17:31
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

2 participants