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

actually test embed_extent #29

Merged
merged 4 commits into from
Dec 24, 2023
Merged

actually test embed_extent #29

merged 4 commits into from
Dec 24, 2023

Conversation

rafaqz
Copy link
Member

@rafaqz rafaqz commented Dec 22, 2023

I added this code without finishing or testing it. So this PR does that.

embed_extent embeds an Extents.Extent object in all geometries recursively. This means extent calls are basically free when you need them later.

Useful as preparation for algorithms that need to call Extents.extent on everything.

@rafaqz rafaqz requested a review from skygering December 22, 2023 18:07
@@ -6,19 +6,24 @@ calculating and adding an `Extents.Extent` to all objects.

This can improve performance when extents need to be checked multiple times.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this could use a bit more comments. I wasn't familiar with this concept and it took a good few minutes to understand what was going on. Maybe a brief description of what extents are and how to access them after running.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh right, I'm assuming a lot of knowledge here. Definately more docs could help!

The ideas is you can use the extent as e.g. a fast pointinpolygon proxy. If its in the extent you need to actually check the polygon, if its not you know in a few ns.

@@ -6,19 +6,24 @@ calculating and adding an `Extents.Extent` to all objects.

This can improve performance when extents need to be checked multiple times.
"""
embed_extent(x; kw...) = apply(AbstractTrait, x; kw...)
embed_extent(x; kw...) = apply(extent_applicator, GI.AbstractTrait, x; kw...)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We also might want to specify here what keywords are possible. Cross-referencing with the with primitives.jl, I can see that it they are: crs, calc_extent, and threaded... however, down below we recalculate crs and we are obviously calculating extent so we might what to specify why we use apply.

Copy link
Member Author

@rafaqz rafaqz Dec 23, 2023

Choose a reason for hiding this comment

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

Ahh probably this can all be written just using one line - apply(identity, PointTrait, x; calc_extent=true) !!!

calc_extent already preopagates the extents efficiently.

And then the threaded and crs keywords make sense. We can just block the calc_extent keyword.

lol

using Test

import GeoInterface as GI
import GeometryOps as GO
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be good to test at least one curve or something that isn't nested since that is a separate function

Copy link
Member Author

Choose a reason for hiding this comment

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

If we use apply for everything than it also needs less tests.

@skygering
Copy link
Collaborator

It seems like the Extents package isn't installed so the tests are failing. Also, we are getting a: Could not use exact versions of packages in manifest warning.

@rafaqz
Copy link
Member Author

rafaqz commented Dec 23, 2023

Ok the code is so simple now this PR is more about adding keyword documentation to all the transformations 🤣

I thought I may as well do that systematically if I added it to embed_extent.

@@ -1,18 +1,31 @@
const THREADED_KEYWORD = "- `threaded`: `true` or `false`. Whether to use multithreading. Defaults to `false`."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh this is such a good way of not having to retype the same documentation over and over. I am so stealing this for my other project 😆

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, from Rasters.jl experience. Actually the main reason is so users see exactly the same things everywhere and it feels consistent

@skygering
Copy link
Collaborator

It is looking really good. I think it might be worth it in some PR, even if not this PR, to clean up the apply file and add some comments. It is not easy to skim and get a grasp on what is going on. But that can be a different PR if you think it is out of scope.

@rafaqz
Copy link
Member Author

rafaqz commented Dec 24, 2023

Yeah I'll add that later

@rafaqz rafaqz merged commit a7286e4 into main Dec 24, 2023
4 checks passed
@rafaqz rafaqz deleted the extent branch December 24, 2023 15:46
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