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
Remove small parts #768
base: master
Are you sure you want to change the base?
Remove small parts #768
Conversation
@gluser1357 Looks like it's failing on our bots treating warnings as errors. Can you fix: https://github.com/postgis/postgis/actions/runs/8474473891/job/23259878295?pr=767
|
We needed a similar function in 2015 and 2018 and published it in SQL form here: https://pgxn.org/dist/lostgis/1.0.0/doc/lostgis.html#ST_FilterSmallRings.sql
|
3e28490
to
3a9d2eb
Compare
I changed variables from signed to unsigned int but I'm not sure if this fixes the problem. Can I start the build myself, or how can I test it the same way as your test (treat warnings as errors)? |
@Komzpa: Thank you for your valuable feedback.
We use this function in order to sort out small areas given by the number of pixels in x and y dimension. In our scenario, the real size of a geometry does not matter, e. g. a filled circle (with a bigger area size) compared with a donut (with a lower area size) shall be treated the same way although the size is very different. I actually also thought about using the area size but then the question arose if the "real" area size of the polygon shall matter (exterior minus interior size) or the area size of each ring (positive or negative). For our use case, it was easier to stay with the x and y dimensions. Since performance does matter I'm not sure if a pure SQL-based function like ST_FilterSmallRings.sql will perform as good as a c-based function. High performance was our main motivation to introduce this function. We choose the word "parts" in removeSmallParts to let the function be generic for all possible shapes (rings, linestrings, polygons, and possibly also other types later on) although currently only (multi)polygons and (multi)linestring types are supported.
We store coordinates in latitude and longitude (EPSG 4326). Without projecting coordinates one could convert pixels to minSizeX and minSizeY where minSizeX can be different from minSizeY for different latitudes (dependent on cosine), allowing to preprocess (=remove small geometry parts) more accurate than assuming minSizeX = minSizeY.
Our idea was to supply one function that can handle all geometry types (polygons, linestrings and later others) and scales (geometry collections, multi-types, polygons, polygon rings and so on) at the same time. But one could limit the function to polygons, yes. ST_Simplify* might have been introduced for a different purpose, but maybe I overlook something? |
Okay rerunning now. |
okay recent change fixed the signed integer issue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you get a chance take a look at @lnicola request for changes
My latest commits contain just some minor edits (comment and formatting cleanup, removal of irrelevant dimension check the same way as in PR #767). Thank you for further reviews, remaining in hope that it'll make it into 3.5.0 :) |
@coderabbitai review |
WalkthroughWalkthroughThe update introduces a new function Changes
Poem
Recent Review DetailsConfiguration used: CodeRabbit UI Files ignored due to path filters (1)
Files selected for processing (7)
Files not reviewed due to errors (1)
Additional comments not posted (12)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Pull request for enhancement request https://trac.osgeo.org/postgis/ticket/5706
See details there, thanks.
Summary by CodeRabbit
New Features
ST_RemoveSmallParts
function to remove small parts from geometries in 2D polygons and polylines, enhancing the precision and usability of geometric data handling.Documentation
ST_RemoveSmallParts
function, including behavior explanations and examples for different geometry types.Tests
ST_RemoveSmallParts
function with various geometries and parameters.