Skip to content

[GH-2183] Fix ST_Buffer logic cap_style when specifying 'side' parameter + Implement rest of geoseries.buffer() - #2184

Merged
jiayuasu merged 6 commits into
apache:masterfrom
petern48:fix_buffer
Jul 29, 2025
Merged

jiayuasu merged 6 commits into
apache:masterfrom
petern48:fix_buffer

Conversation

@petern48

@petern48 petern48 commented Jul 28, 2025 •

Copy link
Copy Markdown
Member

Did you read the Contributor Guide?

Is this PR related to a ticket?

What changes were proposed in this PR?

This PR fixes the following issues in ST_Buffer:

  • We previously were defaulting to cap_style square when side=both was set, but we should be doing it when 'side=left' or 'side=right' is set.
  • Setting this value was not just a default, but a potential override.

Also implemented the rest of geoseries.buffer()

How was this patch tested?

Added tests

Did this PR include necessary documentation updates?

  • No, this PR does not affect any public API so no need to change the documentation. (Fixes a bug so the code behaves as described in the docs)

Comment on lines +396 to +400

// Specifying 'left' or 'right' defaults to square end cap style when side is specified
if (!endCapSpecified) {
bufferParameters.setEndCapStyle(BufferParameters.CAP_SQUARE);
}

@furqaankhan furqaankhan Jul 28, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good catch! Can you add Java tests for this change? And update the docs as well for this behavior change.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added tests and updated the docs toe be more clear @furqaankhan

@petern48
petern48 requested a review from furqaankhan July 29, 2025 01:00
@petern48
petern48 marked this pull request as ready for review July 29, 2025 01:00
@petern48
petern48 requested a review from jiayuasu as a code owner July 29, 2025 01:00
@petern48
petern48 requested a review from zhangfengcdt July 29, 2025 03:03
@jiayuasu
jiayuasu requested a review from Copilot July 29, 2025 06:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes issues in ST_Buffer logic for cap_style parameter handling when the 'side' parameter is specified, and implements additional buffer functionality for GeoSeries. The main changes include correcting the logic that determines when to use square cap style (should apply to 'left' or 'right' side, not 'both'), and ensuring cap_style is only set as a default rather than an override.

  • Fixed cap_style logic in ST_Buffer when side parameter is set to 'left' or 'right'
  • Implemented complete buffer() method for GeoSeries with all parameters (resolution, cap_style, join_style, mitre_limit, single_sided)
  • Added comprehensive test coverage for buffer operations

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
common/src/main/java/org/apache/sedona/common/Functions.java Fixed buffer parameter parsing logic for cap_style when side is specified
python/sedona/geopandas/geoseries.py Implemented full buffer() method with parameter string construction
python/sedona/geopandas/base.py Added comprehensive documentation for buffer() method
python/sedona/spark/sql/st_functions.py Changed default value for useSpheroid parameter
python/tests/geopandas/test_match_geopandas_series.py Added comprehensive buffer parameter testing
python/tests/geopandas/test_geoseries.py Updated buffer tests with new geometries and expected results
python/tests/geopandas/test_geodataframe.py Simplified buffer test implementation
common/src/test/java/org/apache/sedona/common/FunctionsTest.java Added tests for buffer with side and endcap parameters

Comment thread python/sedona/geopandas/geoseries.py Resolved
@github-actions github-actions Bot added the docs label Jul 29, 2025
@jiayuasu jiayuasu added this to the sedona-1.8.0 milestone Jul 29, 2025
@jiayuasu jiayuasu added the bug label Jul 29, 2025
@jiayuasu
jiayuasu merged commit 7ec2e1e into apache:master Jul 29, 2025
@petern48
petern48 deleted the fix_buffer branch October 8, 2025 00:43
@petern48

petern48 commented Oct 8, 2025 •

Copy link
Copy Markdown
Member Author

PostGIS (finally) accepted my PR to update their docs to clarify this behavior as well postgis/postgis#824 🙌

Kontinuation pushed a commit to Kontinuation/sedona that referenced this pull request Jan 21, 2026
…parameter + Implement rest of geoseries.buffer() (apache#2184)

* Implement geoseries.buffer() properly with additional parameters

* Fix ST_Buffer 'side' handling logic

* Add java tests

* mvn spotless

* Update python/sedona/geopandas/geoseries.py

Co-authored-by: Copilot <[email protected]>

* Make docs more clear

---------

Co-authored-by: Jia Yu <[email protected]>
Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ST_Buffer incorrectly sets the cap_style when specifying 'side' parameter

4 participants