Skip to content

Add support for Extent#131

Open
rafaqz wants to merge 2 commits intomainfrom
rs/extents
Open

Add support for Extent#131
rafaqz wants to merge 2 commits intomainfrom
rs/extents

Conversation

@rafaqz
Copy link
Member

@rafaqz rafaqz commented Feb 25, 2026

Add transformations for Extents.Extent. There is a check for rotation/skew etc - an extent is only valid if it remains the actual bounding box after the transormation.

This doesn't actually add a dependency, just makes and existing dependency explicit.

@rafaqz rafaqz changed the title Rs/extents Add support for Extent Feb 25, 2026
return Extents.Extent(merge(NamedTuple(extent), (X=(xmin, xmax), Y=(ymin, ymax))))
end

# Check if corners transform to an axis-aligned rectangle
Copy link
Member

Choose a reason for hiding this comment

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

why do you need this at all, bounds already invokes proj_trans_bounds which densifies the extent and returns it?

Copy link
Member

Choose a reason for hiding this comment

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

this check would seem to make this method completely useless in most cases 😅

Comment on lines +282 to +289
function (trans::Transformation)(extent::Extents.Extent)
haskey(extent, :X) && haskey(extent, :Y) ||
throw(ArgumentError("Extent must have X and Y dimensions"))

_check_axis_aligned(trans, extent) ||
throw(ArgumentError("Cannot transform Extent: CRS is rotated or non-axis-aligned"))

(xmin, xmax), (ymin, ymax) = bounds(trans, extent.X, extent.Y)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
function (trans::Transformation)(extent::Extents.Extent)
haskey(extent, :X) && haskey(extent, :Y) ||
throw(ArgumentError("Extent must have X and Y dimensions"))
_check_axis_aligned(trans, extent) ||
throw(ArgumentError("Cannot transform Extent: CRS is rotated or non-axis-aligned"))
(xmin, xmax), (ymin, ymax) = bounds(trans, extent.X, extent.Y)
function (trans::Transformation)(extent::Extents.Extent; densify_pts = 21)
haskey(extent, :X) && haskey(extent, :Y) ||
throw(ArgumentError("Extent must have X and Y dimensions"))
_check_axis_aligned(trans, extent) ||
throw(ArgumentError("Cannot transform Extent: CRS is rotated or non-axis-aligned"))
(xmin, xmax), (ymin, ymax) = bounds(trans, extent.X, extent.Y; densify_pts)

to pass that kwarg down

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.

2 participants