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

ST_RemoveIrrelevantPointsForView() - Make optimizations based on cartesian math optional #774

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

gluser1357
Copy link

Pull request for enhancement request https://trac.osgeo.org/postgis/ticket/5744
Please see details there.

Copy link

coderabbitai bot commented Jun 13, 2024

Walkthrough

Walkthrough

The changes introduce an optional cartesian_hint parameter to the ST_RemoveIrrelevantPointsForView function across various files. This parameter triggers specific optimizations using Cartesian math, potentially reducing rendering artifacts. Furthermore, the updates include modifying test SQL queries to use this parameter and dropping the existing function signature in the upgrade script.

Changes

File Path Change Summary
doc/reference_editor.xml Added the cartesian_hint parameter to the ST_RemoveIrrelevantPointsForView function documentation.
postgis/lwgeom_remove_irrelevant_points_for_view.c Modified the ST_RemoveIrrelevantPointsForView implementation to include the cartesian_hint parameter.
postgis/postgis.sql.in Added a new optional boolean parameter to ST_RemoveIrrelevantPointsForView function declaration.
regress/core/remove_irrelevant_points_for_view.sql Updated ST_RemoveIrrelevantPointsForView function calls with the additional cartesian_hint argument.
regress/core/remove_irrelevant_points_for_view_expected Introduced new POLYGON entities with varied coordinate points.
postgis/postgis_after_upgrade.sql Implemented function removal operation for ST_RemoveIrrelevantPointsForView(geometry, box2d) using _postgis_drop_function_by_signature.

Sequence Diagrams

sequenceDiagram
    participant User
    participant SQL_Function
    participant Internal_Algo
    User->>SQL_Function: Call ST_RemoveIrrelevantPointsForView with cartesian_hint
    SQL_Function->>Internal_Algo: Pass geometry, bounds, and cartesian_hint
    Internal_Algo->>Internal_Algo: Optimize based on cartesian_hint
    Internal_Algo-->>SQL_Function: Return optimized points
    SQL_Function-->>User: Return result

Poem

🌼 In the land of code so bright and neat,
Geometric wonders do our hearts entreat.
Cartesian hints now steer the view,
With points aligned, a clearer hue.
Farewell old forms, it's time to greet,
The optimized paths beneath our feet. 🌟


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a290aad and e16fadf.

Files selected for processing (1)
  • postgis/postgis_after_upgrade.sql (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • postgis/postgis_after_upgrade.sql

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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

postgis/postgis.sql.in Show resolved Hide resolved
// ===============================================================================
static void removePoints(POINTARRAY *points, GBOX *bounds, bool closed) {
static void removePoints(POINTARRAY *points, GBOX *bounds, bool closed, bool cartesian_hint) {
Copy link
Member

Choose a reason for hiding this comment

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

Any reason why this is not in liblwgeom ? Moving it there would allow adding unit tests for proper memory management debugging

Copy link
Author

Choose a reason for hiding this comment

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

No, actually no special reason. What is the difference between postgis and liblwgeom, and are there other files to be adapted when moving lwgeom_remove_irrelevant_points_for_view.c from postgis to liblwgeom folder? (Same question for lwgeom_st_remove_small_parts.c?)

Copy link
Author

Choose a reason for hiding this comment

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

@strk When I move the .c file to liblwgeom, adapting postgis/Makefile.in and liblwgeom/Makefile.in I get a lot of compiler errors because of missing import statements. I'm not sure how I could resolve them all. Could you please assist me, or would it be an option to leave the file at its current location?

Copy link
Member

Choose a reason for hiding this comment

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

show the errors ? You mean include statement, I guess. The usefulness of moving the code under liblwgeom is for being able to write unit tests which usually catch more errors, especially memory management related.

Copy link
Author

Choose a reason for hiding this comment

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

@strk You are right, I meant include, not import. The errors I get when compiling in /liblwgeom are:

fatal error: postgres.h: No such file or directory
fatal error: funcapi.h: No such file or directory
fatal error: utils/array.h: No such file or directory
fatal error: utils/builtins.h: No such file or directory
fatal error: utils/lsyscache.h: No such file or directory
fatal error: utils/numeric.h: No such file or directory
fatal error: access/htup_details.h: No such file or directory

If I knew how to get rid of these errors I'd try adding cunit tests.

Since IMO there's nothing crucial related to memory management in my code - could we open a new ticket for this refactoring step? I'd like to do the same for ST_RemoveSmallParts. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

The functionality needs be split in two.
One part will only touch LWGEOM object and won't need any of those headers.
The other part will be just a thin wrapper for that liblwgeom function, to expose it to SQL, and only that part will need some of those headers (not all, most likely)

postgis/postgis_after_upgrade.sql Outdated Show resolved Hide resolved
// ===============================================================================
static void removePoints(POINTARRAY *points, GBOX *bounds, bool closed) {
static void removePoints(POINTARRAY *points, GBOX *bounds, bool closed, bool cartesian_hint) {
Copy link
Member

Choose a reason for hiding this comment

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

show the errors ? You mean include statement, I guess. The usefulness of moving the code under liblwgeom is for being able to write unit tests which usually catch more errors, especially memory management related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants