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

enumerate(GI.getpoint(geom)) is not type inferred on polygons #194

Open
asinghvi17 opened this issue Aug 3, 2024 · 3 comments
Open

enumerate(GI.getpoint(geom)) is not type inferred on polygons #194

asinghvi17 opened this issue Aug 3, 2024 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@asinghvi17
Copy link
Member

julia> eltype(enumerate(GI.getpoint(p56)))
Tuple{Int64, Any}

julia> const p5 = p56
GeoInterface.Wrappers.Polygon{false, false, Vector{GeoInterface.Wrappers.LinearRing{false, false, Vector{Tuple{Float64, Float64}}, Nothing, Nothing}}, Nothing, Nothing}(GeoInterface.Wrappers.LinearRing{false, false, Vector{Tuple{Float64, Float64}}, Nothing, Nothing}[GeoInterface.Wrappers.LinearRing{false, false, Vector{Tuple{Float64, Float64}}, Nothing, Nothing}([(0.0, 0.0), (0.0, 10.0), (10.0, 10.0), (10.0, 0.0)], nothing, nothing)], nothing, nothing)

julia> eltype(enumerate(GI.getpoint(p5)))
Tuple{Int64, Any}

julia> typeof(enumerate(GI.getpoint(p5)))
Base.Iterators.Enumerate{Base.Iterators.Flatten{Base.Generator{Vector{GeoInterface.Wrappers.LinearRing{false, false, Vector{Tuple{Float64, Float64}}, Nothing, Nothing}}, GeoInterface.var"#6#7"}}}

Not sure how bad this is for performance - maybe we need a point enumerator wrapper type thing which is known to be type stable (and maybe also known to emit tuple/svector type points)?

@asinghvi17 asinghvi17 added the help wanted Extra attention is needed label Aug 3, 2024
@rafaqz
Copy link
Member

rafaqz commented Aug 3, 2024

What about without enumerate

@asinghvi17
Copy link
Member Author

asinghvi17 commented Aug 3, 2024

That's a vector so type stability is fine I think

Ah, there's the problem. I guess getpoint for polygons returns a Iterators.Flatten which has eltype of Any.

getpoint(GI.getexterior(p56)) is a vector so no worries about eltype there.

@asinghvi17 asinghvi17 changed the title enumerate(GI.getpoint(geom)) is not type inferred enumerate(GI.getpoint(geom)) is not type inferred on polygons Aug 3, 2024
@rafaqz
Copy link
Member

rafaqz commented Aug 3, 2024

Yeah it's double nested for Polygons. We could make a better iterator in GeoInterface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants