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

Add clip parameter to polygon_query; tests missing #670

Merged
merged 2 commits into from
Aug 12, 2024

Conversation

LucaMarconato
Copy link
Member

Closes #644.

This PR adds clip: bool = False as a parameter to polygon_query. The behavior is described in the docstring, that I copy here:

    clip
        If `True`, the shapes are clipped to the polygon. This behavior is implemented only when querying
        polygons/multipolygons or circles, and it is ignored for other types of elements (images, labels, points).
        Importantly, when clipping is enabled, the circles will be converted to polygons before the clipping. This may
        affect downstream operations that rely on the circle radius or on performance, so it is recommended to disable
        clipping when querying circles or when querying a `SpatialData` object that contains circles.

Importantly also:

  • clipping is not enabled for a bounding box query. It will be better to drop the bounding box query implementation for poylgons and points and rely only on the polygon query one, as described here: Plotting cropped Spatialdata leads to polygons protruding the viewport #644
  • I don't entire like the fact that when clipping is enabled the circles are converted to polygons; but it's documented in the docstring, so it should be ok.

@LucaMarconato
Copy link
Member Author

Here is a screenshot:
image

Copy link

codecov bot commented Aug 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.83%. Comparing base (193d930) to head (1cb3f4d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #670   +/-   ##
=======================================
  Coverage   91.83%   91.83%           
=======================================
  Files          44       44           
  Lines        6770     6776    +6     
=======================================
+ Hits         6217     6223    +6     
  Misses        553      553           
Files Coverage Δ
src/spatialdata/_core/query/spatial_query.py 94.73% <100.00%> (+0.08%) ⬆️
src/spatialdata/_core/spatialdata.py 90.89% <ø> (ø)

@LucaMarconato LucaMarconato enabled auto-merge (squash) August 12, 2024 12:30
@LucaMarconato LucaMarconato merged commit 2e1347d into main Aug 12, 2024
8 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.

Plotting cropped Spatialdata leads to polygons protruding the viewport
1 participant