-
Notifications
You must be signed in to change notification settings - Fork 5
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
Geometry return types #45
Comments
Would it be so irritating? LibGeos will still accept that as input. One problem with returning the same type is it's inneficient. Currently we could only do it by calling To get around the cost we would need to write We just dont yet have a dependency free way to make package specific geometries from a vector of tuples except wrapping it as a GI shape and calling I would also suggest we shouldnt return C objects no matter what the input is... |
With |
Oh my gosh, I didn't know that LibGEOS could take in GI shapes. That is a game-changer! I agree that we shouldn't return C objects. So that throws out returning the input type. I am hoping to minimize type instability. Obviously, there will be some just due to the nature of these problems. I was thinking if we returned the same coordinate form always, it wouldn't be type unstable. But then it is up to the user to untangle the type, which also doesn't seem great. Any thoughts about how to minimize type instability? |
Yeah its pretty nice and tivial to implement now we have
Type stability is really case by case if you have some examples where its bad we can analyze it. |
Or I guess like in my code. If I take the |
Except for deep nested recursion in At worst it should be small union instabilities. |
Do you use ProfileView.jl and Cthulhu.jl to look into instability? |
I have yeah! I probably need to more though! I guess I don't see how things like |
Can intersection of two polygons return a line or point? Or just another polygon (that maybe does only cover a line or single point)? |
In LibGEOS, it can return a Point, a Line, a Polygon, a MultiPolygon, even a GeometryCollection or an Empty Polygon. |
Really? Ok yes that cant ever be type stable. We can at least list the possible types manually in a Union I guess... |
We could do something different. I am not sure of a good general solution though. My solution right now is that everything that comes out of those functions is run through a get_polygons function that returns a vector of polygons since that is all that I use, but obviously, that isn't what everyone needs. |
We could have a keyword where you pass the traits you want, which would skip around the type instability |
Ah! That would be so nice. Then I don't have to have the stupid extra function haha. What do you think is a good return type if there aren't any? |
If it would be a vector of polygons otherwise it can be an empty vector? Then it can be totally type stable given a trait. |
I feel like we should have an option to do that and maybe an option that is type unstable and returns what LibGEOS returns. Or can we just not do that since type instability is such a Julia sin? |
I think both is best |
I wanted to start a conversation about what return types of functions that create geometries should be. For example,
simplify
, if given aLibGEOS.Polygon
as an input, still returns aGeoInterface.Polygon
. This can be kinda irritating for users. This problem becomes even more pronounced with things likeunion
,difference
, andintersection
, which my intern is working on a PR for (probably in the next week). Should they all returnGI
shapes? Should they return coordinates (and a trait type maybe)? Should they rebuild the same type as the input? What do we think is best?Would love your opinions @rafaqz @asinghvi17.
The text was updated successfully, but these errors were encountered: