Skip to content

Add interpolations#16

Merged
rafaqz merged 15 commits intoMakieOrg:masterfrom
gaelforget:AddInterpolations
Apr 29, 2023
Merged

Add interpolations#16
rafaqz merged 15 commits intoMakieOrg:masterfrom
gaelforget:AddInterpolations

Conversation

@gaelforget
Copy link
Copy Markdown
Contributor

@gaelforget gaelforget commented Jan 21, 2023

This lets you override the fetching of tiles (from local or remote file) to use an interpolator to fill up the tiles on the fly.

Side benefits : this lets you try/test things out offline / without access to files or urls; or project any array or image onto the tile space.

Some notes

That's pretty much what I used in https://youtu.be/6pvKW1hcghg using output from a climate model via such an interpolator.

Several things can be improved. I may have gotten confused wrt North/South direction, maybe? Also should mention that I wasn't immediately able to make docs. The example could be used for test but I did not do it.

Others are question marks. I could imagine AbstractProvider definition moving to Tyler, or module ForInterpolations moving to TileProviders alternatively, or maybe all is fine as done here; maybe I could have PR'ed the lng2tile etc functions to MapTiles.jl.

@gaelforget
Copy link
Copy Markdown
Contributor Author

requires JuliaGeo/TileProviders.jl#5

@lazarusA
Copy link
Copy Markdown
Collaborator

@gaelforget it looks like you didn't add Interpolations to the Docs Project.toml, hence the failure. The environment is independent to the one for base Tyler. Also, for every new file.jl for docs, you need to add an entry after here with the same name as the file but now with md, i.e. file.md :

- "OSMMakie integration" : "examples/generated/UserGuide/osmmakie.md"
.

As for the right place and style for https://github.com/MakieOrg/Tyler.jl/pull/16/files#diff-3b196dbeff13910024b55eb38dbb48b8bd8d51d698d330ab200031de29ac4e90 @SimonDanisch might have some opinion about it.

@lazarusA lazarusA mentioned this pull request Jan 21, 2023
@gaelforget
Copy link
Copy Markdown
Contributor Author

@gaelforget it looks like you didn't add Interpolations to the Docs Project.toml, hence the failure. The environment is independent to the one for base Tyler. Also, for every new file.jl for docs, you need to add an entry after here with the same name as the file but now with md, i.e. file.md :

- "OSMMakie integration" : "examples/generated/UserGuide/osmmakie.md"

.
As for the right place and style for https://github.com/MakieOrg/Tyler.jl/pull/16/files#diff-3b196dbeff13910024b55eb38dbb48b8bd8d51d698d330ab200031de29ac4e90 @SimonDanisch might have some opinion about it.

Sounds good. Thanks for the feedback and pointers.

@gaelforget
Copy link
Copy Markdown
Contributor Author

gaelforget commented Jan 22, 2023

@gaelforget it looks like you didn't add Interpolations to the Docs Project.toml, hence the failure. The environment is independent to the one for base Tyler. Also, for every new file.jl for docs, you need to add an entry after here with the same name as the file but now with md, i.e. file.md :

- "OSMMakie integration" : "examples/generated/UserGuide/osmmakie.md"

Thanks. Should be done now. See ci and documenter workflows.

@gaelforget
Copy link
Copy Markdown
Contributor Author

gaelforget commented Mar 2, 2023

Just merged master into branch and reran actions. ci and documenter workflows seem aok.

Could this be merged? further reviewed?

src/Tyler.jl Outdated

function fetch_tile(tyler::Map, tile::Tile)
return get!(tyler.fetched_tiles, tile) do
if isa(tyler.provider,Interpolator)
Copy link
Copy Markdown
Collaborator

@rafaqz rafaqz Mar 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could use a function and dispatch instead? It's the only thing hard coding the Interpolations dep.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 0c7d17d , 2c6ad84

col(i)=RGBAf(Makie.interpolated_getindex(cols,i))
col(i::RGBAf)=i

function fetch_tile(provider::Interpolator, tile::Tile)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could go in the interpolator module

(lons,lats)
end

struct Interpolator <: AbstractProvider
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could do with some docs? I know the rest of the package is pretty short on docs, but it would be good to know what url and options are

array=(array.-minimum(array))./(maximum(array)-minimum(array))
itp = interpolate(nodes, array, Gridded(Linear()))
cols=Makie.to_colormap(:viridis)
col(i)=RGBAf(Makie.interpolated_getindex(cols,i))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't these be part of Interpolator? It seems like some unnecessary work to set it up.

They could be keywords if people did need to customise?

@rafaqz rafaqz merged commit 5fb0624 into MakieOrg:master Apr 29, 2023
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.

4 participants