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

Coverage Simplification, Validation, Union #731

Merged
merged 16 commits into from
May 3, 2023

Conversation

pramsey
Copy link
Member

@pramsey pramsey commented Apr 25, 2023

Adds three new functions,

  • ST_CoverageIsValid(geom geometry winset, tolerance float8)
  • ST_CoverageSimplify(geom geometry winset, tolerance float8, simplifyBoundary integer)
  • ST_CoverageUnion(geom geometry set)

For the purpose of these functions a "coverage" is a set of polygons with perfectly shared edges (no overlaps or gaps and exact vertex matching).

@robe2
Copy link
Member

robe2 commented Apr 26, 2023

@pramsey your documentation is missing mention of minimum required GEOS.

@robe2
Copy link
Member

robe2 commented Apr 26, 2023

Garden crash:

SELECT ST_CoverageIsValid( ST_GeomFromText('MULTIPOLYGON (((9 9, 9 1, 1 1, 2 4, 7 7, 9 9)), EMPTY)', 4326)) OVER(ORDER BY random());

@dr-jts
Copy link
Contributor

dr-jts commented Apr 26, 2023

Garden crash:

SELECT ST_CoverageIsValid( ST_GeomFromText('MULTIPOLYGON (((9 9, 9 1, 1 1, 2 4, 7 7, 9 9)), EMPTY)', 4326)) OVER(ORDER BY random());

@robe2 yes, that's a known issue. I'm in the process of fixing it.

@robe2
Copy link
Member

robe2 commented Apr 26, 2023

@pramsey if you want to commit, I'm fine with that. GHA latest is passing now after the build.

The berries will fail at their garden test step until the crash issue is fixed in GEOS.

@robe2 robe2 self-requested a review April 26, 2023 17:47
@robe2
Copy link
Member

robe2 commented May 2, 2023

Am I allowed to be petty @pramsey ?

The ST_CoverageIsValid doesn't sound like it should return a geometry. The function seems misnamed.

Maybe it should be named ST_CoverageInvalidElements

@dr-jts
Copy link
Contributor

dr-jts commented May 2, 2023

The ST_CoverageIsValid doesn't sound like it should return a geometry. The function seems misnamed.

Agreed, this sounds like it should return a boolean.

How about ST_CoverageInvalidLocation(s)? I tend towards the plural form, but either is good.

Aside: we have kicked around the idea of an aggregate function returning a boolean, to report whether a set of polygonal geometries forms a valid coverage. ST_CoverageIsValid would be a good name for this function. We haven't proceeded on this because it is really just a wrapper over ST_CoverageInvalidLocations, and doesn't return as much information. But maybe it will become apparent that it is useful in the future.

@robe2
Copy link
Member

robe2 commented May 2, 2023

The ST_CoverageIsValid doesn't sound like it should return a geometry. The function seems misnamed.

Agreed, this sounds like it should return a boolean.

How about ST_CoverageInvalidLocation(s)? I tend towards the plural form, but either is good.

Aside: we have kicked around the idea of an aggregate function returning a boolean, to report whether a set of polygonal geometries forms a valid coverage. ST_CoverageIsValid would be a good name for this function. We haven't proceeded on this because it is really just a wrapper over ST_CoverageInvalidLocations, and doesn't return as much information. But maybe it will become apparent that it is useful in the future.

I'm 0.52 for non-plural and 0.48 for plural based on a total weighting of 1

@pramsey
Copy link
Member Author

pramsey commented May 2, 2023

Changed to ST_CoverageInvalidLocations

@robe2
Copy link
Member

robe2 commented May 3, 2023

@pramsey I rebuilt the docker image and reran latest. All tests are passing now. Anything else you are waiting on before you commit?

doc/reference_coverage.xml Outdated Show resolved Hide resolved
doc/reference_coverage.xml Outdated Show resolved Hide resolved
doc/reference_coverage.xml Outdated Show resolved Hide resolved
doc/reference_coverage.xml Show resolved Hide resolved
doc/reference_coverage.xml Outdated Show resolved Hide resolved
doc/reference_coverage.xml Outdated Show resolved Hide resolved
doc/reference_coverage.xml Outdated Show resolved Hide resolved
doc/reference_coverage.xml Outdated Show resolved Hide resolved
doc/reference_coverage.xml Outdated Show resolved Hide resolved

Datum ST_CoverageUnion(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(ST_CoverageUnion);
Datum ST_CoverageUnion(PG_FUNCTION_ARGS)
Copy link
Member

Choose a reason for hiding this comment

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

Would this make more sense in lwgeom_geos.c ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I dunno that the extra layer of indirection is a big win? What's the argument for?

Copy link
Member

Choose a reason for hiding this comment

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

To be clear, I meant postgis/lwgeom_geos.c. I just noticed that it was in lwgeom_window.c but is not a window function.

Copy link
Member Author

Choose a reason for hiding this comment

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

Potato / potato. Could move it but then it would be separate from its coverage friends...

@pramsey pramsey merged commit ce75a0e into postgis:master May 3, 2023
@pramsey pramsey deleted the master-coverages branch May 23, 2023 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants