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

some editing of #33 #49

Merged
merged 7 commits into from
May 15, 2022
Merged

some editing of #33 #49

merged 7 commits into from
May 15, 2022

Conversation

visr
Copy link
Member

@visr visr commented May 15, 2022

Nothing major, but I'm making some edits as I go over the current status of the #33 branch (which looks quite good overall!).

visr added 5 commits May 15, 2022 13:33
This fits the header description better, and is the same filename as used for Tables.jl
This makes it more clear what the unused argument is supposed to be.
@visr
Copy link
Member Author

visr commented May 15, 2022

One thing I want to make sure, in the test implementation there was a

GeoInterface.convert(::Type{MyCurve}, ::GeoInterface.LineStringTrait, geom) = geom

That should be a Base.convert right? That is what I did here.

@visr visr mentioned this pull request May 15, 2022
@evetion
Copy link
Member

evetion commented May 15, 2022

One thing I want to make sure, in the test implementation there was a

GeoInterface.convert(::Type{MyCurve}, ::GeoInterface.LineStringTrait, geom) = geom

That should be a Base.convert right? That is what I did here.

Probably not. I struggled with this myself, but we cannot define it here without overriding Base.convert(::Any, ::Any). I'm not sure if that's something we want. Then again, it would work better if it did though?

@rafaqz

@rafaqz
Copy link
Member

rafaqz commented May 15, 2022

Yeah that's a little tricky. Can we internally do:

Base.convert(::Type, ::AbstractGeometryTrait, geom) = error("some comvert error asking for a method to be defined")

And just get packages to define:

Base.convert(::Type{T}, geom) where T<:AbstractPackageType = Base.convert(T, geomtype(geom), geom)

(or make another macro like with plots)

@evetion evetion merged commit 8468fa9 into v1-traits May 15, 2022
@visr visr deleted the check branch May 15, 2022 16:31
@evetion
Copy link
Member

evetion commented May 15, 2022

@rafaqz @visr
I've implemented the suggestion above in 2cc0e07 (#33). One tricky thing, convert is also called in the iteration we provide ourselve (like getgeom). So we need to provide another method:

Base.convert(::Type{X}, ::LineStringTrait, geom::X) = geom  # fast fallthrough without conversion    

Otherwise the convert will handle the geom as if it's another geometry altogether, getting coordinates, making copies, etc.

@visr
Copy link
Member Author

visr commented May 19, 2022

I see now only Base.convert in the docs: https://github.com/JuliaGeo/GeoInterface.jl/blob/e34d37e59cda58a9b0adbe98e95f593a8cd29d35/docs/src/guides/developer.md#conversion

Does that mean that these can be removed?

convert(T, geom) = convert(T, geomtrait(geom), geom)

GeoInterface.convert(::Type{MyCurve}, ::GeoInterface.LineStringTrait, geom) = geom

@visr visr mentioned this pull request Aug 3, 2022
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 this pull request may close these issues.

None yet

3 participants