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

GI.extent can sometimes return nothing, not calculating the extent? #94

Open
asinghvi17 opened this issue Dec 27, 2024 · 2 comments · May be fixed by #95
Open

GI.extent can sometimes return nothing, not calculating the extent? #94

asinghvi17 opened this issue Dec 27, 2024 · 2 comments · May be fixed by #95

Comments

@asinghvi17
Copy link
Member

See this GeoJSON file, try to get the extents of each geometry. It ends up being a vector of nothings.

# Any GeoJSON Object
GI.extent(::GI.FeatureTrait, x::GeoJSONT{2}) = _extent2(x)
GI.extent(::GI.FeatureCollectionTrait, x::GeoJSONT{2}) = _extent2(x)
GI.extent(::GI.AbstractGeometryTrait, x::GeoJSONT{2}) = _extent2(x)
GI.extent(::GI.FeatureTrait, x::GeoJSONT{3}) = _extent3(x)
GI.extent(::GI.FeatureCollectionTrait, x::GeoJSONT{3}) = _extent3(x)
GI.extent(::GI.AbstractGeometryTrait, x::GeoJSONT{3}) = _extent3(x)
function _extent3(x)
bb = bbox(x)
isnothing(bb) ? nothing :
Extents.Extent(
X=(bb[1], bb[4]),
Y=(bb[2], bb[5]),
Z=(bb[3], bb[6]),
)
end
function _extent2(x)
bb = bbox(x)
ex = isnothing(bb) ? nothing : Extents.Extent(X=(bb[1], bb[3]), Y=(bb[2], bb[4]))
return ex
end

shows that we deliberately return nothing if there is no precomputed extent. But the promise of GI.extent was (to my understanding) that it falls back to actually calculating the extent if it has to.

So should we edit this in the GI.extent definition?

@rafaqz
Copy link
Member

rafaqz commented Dec 27, 2024

That code is just wrong now, it's from before we calculated. It should define Extents.extent to return an extent or nothing and not mess with GIs auto extent

@asinghvi17 asinghvi17 linked a pull request Dec 27, 2024 that will close this issue
@asinghvi17
Copy link
Member Author

export copy.json

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.

2 participants