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

getInteriorPoint does not intersect narrow polygon #359

Closed
dbaston opened this issue Dec 13, 2018 · 4 comments
Closed

getInteriorPoint does not intersect narrow polygon #359

dbaston opened this issue Dec 13, 2018 · 4 comments

Comments

@dbaston
Copy link
Contributor

dbaston commented Dec 13, 2018

An interior point generated from the following polygon is not found to intersect the polygon.

POLYGON ((2.0875049999999997 49.038467, 2.087497642793396 49.0384427212182, 2.087475 49.038368, 2.0875049999999997 49.038467))

As reported in https://trac.osgeo.org/postgis/ticket/4274

@dr-jts
Copy link
Contributor

dr-jts commented Dec 13, 2018

Well, yes... that's a pretty narrow polygon. 2.8E-16 width, in fact.

Have to think about what to do about this... This might be solvable by a better intersection computation (i.e. using extended precision).

Although, there is a public warning in the FAQ about this kind of thing: https://locationtech.github.io/jts/jts-faq.html#D7

Side note: I intend to improve the PointInArea computation using this code in the TestBuilder. The reason is to avoid calling Geometry.intersection(), which is expensive and non-robust. That would be a good time to look at this problem.

@dr-jts
Copy link
Contributor

dr-jts commented Dec 13, 2018

Really this is more of a "finite-precision" issue than an actual robustness failure. There are just some limitations to working in finite-precision floating point which cannot be worked around.

Perhaps the best that can be done at some point is to implement a tolerance/precision model for predicate calculations (which is the to-do list, and seems tractable).

@dr-jts dr-jts changed the title getInteriorPoint robustness failure getInteriorPoint does not intersect narrow polygon Feb 5, 2019
@dr-jts
Copy link
Contributor

dr-jts commented Feb 12, 2019

Perhaps the simplest thing to do is to detect that the computed interior point does not intersect the polygon, and simply return a vertex of the polygon. This is not ideal, but may improve the outcome of some use cases (or then again, it may make them worse - hard to know without some real-world experience).

In fact I'm about to land an improved InteriorPointArea which has this behaviour (#369). So perhaps this will provide some feedback.

@dr-jts
Copy link
Contributor

dr-jts commented Feb 13, 2019

Possibly fixed by #369

@dr-jts dr-jts closed this as completed Feb 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants