-
Notifications
You must be signed in to change notification settings - Fork 4
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
Sg/area dist debug #33
Conversation
Sg/update intersects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to either pick a fixed floating point output type (e.g. Float64
), or detect it once very early and push that through. Then all those zeros will be type stable and we cont need to do the zero(typeof(x(...
src/methods/area.jl
Outdated
function area(::GI.MultiPointTrait, multipoint) | ||
GI.isempty(multipoint) && return 0 | ||
np = GI.npoint(multipoint) | ||
np == 0 && return 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make area always return Float64
for type stability?
Another option is to check the type once at the start, then push it through as the first argument T
to an _area(T, trait, geom)
method that returns e.g. zero(T)
. We can let users specify it too if they need to
src/methods/area.jl
Outdated
function area(::CT, curve) where CT <: GI.AbstractCurveTrait | ||
GI.isempty(curve) && return 0 | ||
np = GI.npoint(curve) | ||
np == 0 && return 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
I wanted to preserve the flexibility so that if I run a simulation with Float32 or Float64 polygons, the area returns the correct type. But I can see why that is tricky, especially with the empty geometries for which we would have to default to something. Do you think it is better just for it to return |
Maybe default to Float64 but let the user pass in the type? |
Okay, I updated the type stuff! They all have optional parameters now. I also just simplified some stuff. Something I am noting is that I am doing As discussed in #32, this can be problematic if a library does a poor job of implementing GeoInterface. I kinda feel like that is the library's fault though, not ours. For example, using However, if you think this is still slower than |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it will be much faster :)
Lets not worry about getgeom
for now. But I do worry that getting individual points from LibGeos or ArchGDAL will never be fast (and geointerface should actually caution against operating at the point level too much)
I realized that I missed a few geometry types that were coming up in my simulations.
I also realized that my code failed with empty geometries as it was trying to access the first point. This then led me to the discovery of an issue with the implementation of
isempty
at least with LibGEOS. So now I have to checkisempty
and find if there is a non-zero number of points to determine the type of the points within a geometry that returns an area of 0.This seems like too much work just to return 0. I am wondering if it would be bad to just return an
Int
0 for everything but non-empty polygons / multipolygon / collections.This isn't the best type-wise, but there is no guarantee that we can even determine the type.
Thoughts?