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

Fix polygon validation function (issue #112) #113

Merged
merged 2 commits into from
Dec 8, 2023

Conversation

vitcpp
Copy link
Contributor

@vitcpp vitcpp commented Dec 5, 2023

No description provided.

Some previous changes to improve the behaviour in case of degenerate
poygons introduced a bug in the polygon validation function. The
changes are rolled back.
@vitcpp vitcpp linked an issue Dec 5, 2023 that may be closed by this pull request
An extra change is introduced as well: generate empty upgrade scripts
without the need to create *.sql.in files in upgrade_script
subdirectory.
---------------------------------
{(0d , 1d),(0d , 2d),(0d , 3d)}
(1 row)

Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem correct. This spoly and the following one should fail, no? They do not seem to be valid polygons to me.

Copy link
Contributor Author

@vitcpp vitcpp Dec 5, 2023

Choose a reason for hiding this comment

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

@esabol I rolled back the changes in PR #36 because it broke the creation of valid polygons. I looked at the issue where we decided to consider degenerate polygons as invalid, but I can't remember why we decided to so, unfortunately. Probably, due to OGC specification of valid polygons. This bug actually makes pgsphere unusable in production, but invalidation of degenerate polygons don't produce any problems. Despite of OGC specification of valid polygons, in practice, we may consider support of genenerate polygons as well to make pgsphere more usable.

P.S. Polygons with intersecting edges are really invalid and can not be used in calculations. But degenerate polygons do not break algorithms.

P.P.S I remembered our discussions. The key point was that not all types of degenerate polygons were supported. To make the consistent behaviour we decided to disable support of degenerate polygons. But the proposed and merged patch breaks the support for valid polygons and it should be fixed asap. I propose to fix it and think how to improve that function one more time.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather see the validation of polygons fixed instead of disabled. I disagree that the current version is "unusable". We've been using this version in production, and we have not encountered any issues with our polygons, but I guess we've just been lucky.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@esabol I understand the problem with sline_sline_pos. I'm going to propose another solution but it takes more time to implement and test. The core reason is in using of spoint_at_sline in sline_sline_pos before checking for connectivity of adjacent segments. In past, the connectivity check was prior to the calling of spoint_at_sline.

I believe it is reasonable to apply this PR and increment patch number, because the big is severe. But next commit we improve sline_sline_pos. It more risky and needs more testing.

{
return PGS_LINE_CONNECT;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to add a test for this change to sline_sline_pos()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@esabol I think, the added polygon allows to test this branch in the code. Otherwise, it goes down in the function and returns wrong relationship. The current change just rolls back the old commit. I propose to fix degenerate polygons later, in another commit.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK. Sounds good, @vitcpp.

@vitcpp vitcpp merged commit 0be5757 into postgrespro:master Dec 8, 2023
14 checks passed
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.

spoly that was valid now detected as invalid
2 participants