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

Type stable calc extent #98

Merged
merged 14 commits into from
Aug 7, 2023
Merged

Type stable calc extent #98

merged 14 commits into from
Aug 7, 2023

Conversation

rafaqz
Copy link
Member

@rafaqz rafaqz commented Apr 29, 2023

@asinghvi17 hit some very slow code with Rasters.jl and GeometryBasics.jl where I had forgotten to use fallbacks=false.

But it seems it can be a lot faster by using is3d to in worst case get small union optimisations (but mostly compiled away), getting the extrema over all points in a geometry in one pass, and avoiding collecting points or making NamedTuple at the leaf nodes of the geometry.

@rafaqz rafaqz requested a review from evetion May 4, 2023 23:38
@evetion
Copy link
Member

evetion commented Jul 22, 2023

This looks nice! Can we add a test for the type stability (or hit the missing coverage)?

@rafaqz
Copy link
Member Author

rafaqz commented Jul 29, 2023

Its a small union optimisation, so its not guaranteed to be inferred, just fast.

I'll try to get the code coverage up

@rafaqz
Copy link
Member Author

rafaqz commented Aug 5, 2023

@evetion this is good to go if you could approve, coverage is passing

(needs a squash and cleanup rather than merge tho)

Extent(; X, Y)
end
end
calc_extent(t::GeometryCollectionTrait, geom) = reduce(Extents.union, (extent(f) for f in getgeom(t, geom)))
Copy link
Member

Choose a reason for hiding this comment

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

pedantry: note that we call extent (and thus accept pre-calculated extents) for multigeoms instead of calling calc_extent (recalculating everything). Old behaviour and quite pragmatic, but it might be slightly unexpected.

@evetion evetion merged commit 79c7783 into main Aug 7, 2023
10 checks passed
@evetion evetion deleted the type_stable_calc_extent branch August 7, 2023 06:55
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