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 a coordtype method #128

Open
rafaqz opened this issue Apr 17, 2024 · 4 comments · May be fixed by #167
Open

Add a coordtype method #128

rafaqz opened this issue Apr 17, 2024 · 4 comments · May be fixed by #167

Comments

@rafaqz
Copy link
Member

rafaqz commented Apr 17, 2024

I'm not sure if this is possible (do any formats allow mixed coordinate types like Float32 and Float64 in the same dataset on even the same polygon??)

But it would be good to be able to get the coord type at any level, e.g. on a feature or polygon as well as a point. Then we can pass it into loops to fix type stability, and use it to e.g. preallocate vectors.

@asinghvi17 @skygering were discussing this on slack recently. Currently in GeometryOps,jl we just default to Float64 and allow user override. But it could be nice to detect the coord type and use that.

@asinghvi17
Copy link
Member

Formats would not allow mixed coordinate types but it would be super useful to have e.g. Unitful support.

@rafaqz
Copy link
Member Author

rafaqz commented Sep 25, 2024

This could also be extremely useful for fixing empty collection problems

@rafaqz rafaqz linked a pull request Sep 25, 2024 that will close this issue
@evetion
Copy link
Member

evetion commented Sep 28, 2024

This could also be extremely useful for fixing empty collection problems

Can you give an example?

@rafaqz
Copy link
Member Author

rafaqz commented Sep 28, 2024

Say we know some operation ends in an empty vector of points, what type is the vector? If we have coordtype we can at least find that it's Tuple{T,T}[]. We can also allocate vectors like this up front to save memory sometimes, if we know T in all cases including the empty case.

Currently handling the empty case is expensive because it can introduce type instability because we don't know T.

But for example, if a GeoJSON geom is empty, we always know T is Float64 anyway because coordtype returns it. Then doing an operation over a vector of GeoJSON geoms we get the same return type every time.

It would actually be most useful to get T from the geometry type, I'm just not sure we can always do that. Is there any package where its not possible?

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 a pull request may close this issue.

3 participants