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

[WIP] Improvements to GeoAxis and docs #207

Merged
merged 103 commits into from
Jun 6, 2024
Merged

[WIP] Improvements to GeoAxis and docs #207

merged 103 commits into from
Jun 6, 2024

Conversation

asinghvi17
Copy link
Member

@asinghvi17 asinghvi17 commented Mar 3, 2024

Updates to Makie v0.21 and adds a couple of improvements to GeoAxis. Also gets rid of PROJ_RESCALE_FACTOR since we can now use Float64 numbers.

This PR requires Makie v0.21 and is only usable with those versions of Makie.

View the docs at https://geo.makie.org/previews/PR207

Full changelog

  • Converted all internal computations to use Float64 instead of Float32 thanks to @ffreyer's and the Makie team's work in Makie.jl v0.21.
    • Consequently, the PROJ_RESCALE_FACTOR hack is also removed.
    • Zooming in close should also work now, with the correct ticks being shown.
  • Added the option to provide an integer scale in coastlines and land, which triggers GeoMakie to get data from NaturalEarth.jl instead of using the bundled data.
  • Updated the to_multipoly function to use GeoInterface traits, so that it's more universal.
  • Added several new examples - tissot.jl, source_crs.jl, etc.
  • Added dependencies to Project.toml:
    • GeoFormatTypes.jl for possible integration / GI.crs on GeoAxis
    • NaturalEarth.jl as mentioned above
    • GeometryOps.jl for potential antimeridian cutting and other geometry routines (not used yet, but will be used soon)

@asinghvi17 asinghvi17 changed the title Improvements to GeoAxis and docs [WIP] Improvements to GeoAxis and docs Mar 3, 2024
@asinghvi17
Copy link
Member Author

This PR currently needs:
JuliaGeometry/GeometryBasics.jl#214
MakieOrg/Makie.jl#3681 (and GLMakie, MakieCore on the same branch)

@felixcremer
Copy link

This fails to precompile for me with the following error:

ERROR: LoadError: Failed to precompile Makie [ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a] to "/home/fcremer/.julia/compiled/v1.10/Makie/jl_pajWTX".
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
    @ Base ./loading.jl:2468
  [3] compilecache
    @ ./loading.jl:2340 [inlined]
  [4] (::Base.var"#968#969"{Base.PkgId})()
    @ Base ./loading.jl:1974
  [5] mkpidlock(f::Base.var"#968#969"{Base.PkgId}, at::String, pid::Int32; kwopts::@Kwargs{stale_age::Int64, wait::Bool})
    @ FileWatching.Pidfile ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:93
  [6] #mkpidlock#6
    @ ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:88 [inlined]
  [7] trymkpidlock(::Function, ::Vararg{Any}; kwargs::@Kwargs{stale_age::Int64})
    @ FileWatching.Pidfile ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:111
  [8] #invokelatest#2
    @ ./essentials.jl:894 [inlined]
  [9] invokelatest
    @ ./essentials.jl:889 [inlined]
 [10] maybe_cachefile_lock(f::Base.var"#968#969"{Base.PkgId}, pkg::Base.PkgId, srcpath::String; stale_age::Int64)
    @ Base ./loading.jl:2983
 [11] maybe_cachefile_lock
    @ ./loading.jl:2980 [inlined]
 [12] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1970
 [13] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1812
 [14] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
 [15] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [16] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1803
 [17] macro expansion
    @ ./loading.jl:1790 [inlined]
 [18] macro expansion
    @ ./lock.jl:267 [inlined]
 [19] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1753
 [20] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
 [21] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [22] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1746
 [23] include
    @ ./Base.jl:495 [inlined]
 [24] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
    @ Base ./loading.jl:2222
 [25] top-level scope
    @ stdin:3
in expression starting at /home/fcremer/Documents/rqa_bonito_app/dev/GeoMakie/src/GeoMakie.jl:1
in expression starting at stdin:3
Makie [ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a]

Failed to precompile Makie [ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a] to "/home/fcremer/.julia/compiled/v1.10/Makie/jl_wR6ngy".
ERROR: LoadError: MethodError: Cannot `convert` an object of type Observables.Observable{GeometryBasics.Vec{2, Float32}} to an object of type Float32

Closest candidates are:
  convert(::Type{T}, ::DualNumbers.Dual) where T<:Union{Real, Complex}
   @ DualNumbers ~/.julia/packages/DualNumbers/5knFX/src/dual.jl:24
  convert(::Type{T}, ::T) where T
   @ Base Base.jl:84
  convert(::Type{T}, ::Polynomials.AbstractPolynomial{T, X}) where {T<:Number, X}
   @ Polynomials ~/.julia/packages/Polynomials/UpyN2/src/common.jl:476
  ...

Stacktrace:
  [1] (::GeometryBasics.var"#5#16"{Float32, Observables.Observable{GeometryBasics.Vec{2, Float32}}})(i::Int64)
    @ GeometryBasics ~/.julia/packages/GeometryBasics/7UOa3/src/fixed_arrays.jl:45
  [2] ntuple
    @ ./ntuple.jl:49 [inlined]
  [3] GeometryBasics.Point{2, Float32}(x::Observables.Observable{GeometryBasics.Vec{2, Float32}})
    @ GeometryBasics ~/.julia/packages/GeometryBasics/7UOa3/src/fixed_arrays.jl:45
  [4] to_world(scene::Makie.Scene, point::GeometryBasics.Point{2, Float32})
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/camera/projection_math.jl:243
  [5] mouseposition(scene::Makie.Scene)
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/interaction/interactive_api.jl:190
  [6] _addmouseevents!(scene::Makie.Scene, is_mouse_over_relevant_area::Makie.var"#is_mouse_over_relevant_area#1464"{Makie.Scene, Tuple{}}, priority::Int64)
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/mousestatemachine.jl:197
  [7] addmouseevents!(::Makie.Scene; priority::Int64)
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/mousestatemachine.jl:125
  [8] addmouseevents!(::Makie.Scene)
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/mousestatemachine.jl:123
  [9] register_events!(ax::Makie.Axis, scene::Makie.Scene)
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/blocks/axis.jl:35
 [10] initialize_block!(ax::Makie.Axis; palette::Nothing)
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/blocks/axis.jl:501
 [11] initialize_block!(ax::Makie.Axis)
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/blocks/axis.jl:163
 [12] _block(T::Type{Makie.Axis}, fig_or_scene::Makie.Figure, args::Vector{Any}, kwdict::Dict{Symbol, Any}, bbox::Nothing; kwdict_complete::Bool)
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/blocks.jl:362
 [13] _block(T::Type{Makie.Axis}, fig_or_scene::Makie.Figure, args::Vector{Any}, kwdict::Dict{Symbol, Any}, bbox::Nothing)
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/blocks.jl:282
 [14] _block(::Type{Makie.Axis}, ::Makie.Figure; bbox::Nothing, kwargs::@Kwargs{})
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/blocks.jl:250
 [15] _block(::Type{Makie.Axis}, ::Makie.Figure)
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/blocks.jl:249
 [16] _block(::Type{Makie.Axis}, ::GridLayoutBase.GridPosition; kwargs::@Kwargs{})
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/blocks.jl:244
 [17] _block
    @ ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/blocks.jl:237 [inlined]
 [18] #_#1373
    @ ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/blocks.jl:228 [inlined]
 [19] Block
    @ ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/blocks.jl:227 [inlined]
 [20] macro expansion
    @ ~/Documents/rqa_bonito_app/dev/Makie/src/precompiles.jl:29 [inlined]
 [21] macro expansion
    @ ~/.julia/packages/PrecompileTools/L8A3n/src/workloads.jl:78 [inlined]
 [22] top-level scope
    @ ~/Documents/rqa_bonito_app/dev/Makie/src/precompiles.jl:27
 [23] include(mod::Module, _path::String)
    @ Base ./Base.jl:495
 [24] include(x::String)
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/Makie.jl:1
 [25] top-level scope
    @ ~/Documents/rqa_bonito_app/dev/Makie/src/Makie.jl:408
 [26] include
    @ ./Base.jl:495 [inlined]
 [27] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
    @ Base ./loading.jl:2222
 [28] top-level scope
    @ stdin:3
in expression starting at /home/fcremer/Documents/rqa_bonito_app/dev/Makie/src/precompiles.jl:26
in expression starting at /home/fcremer/Documents/rqa_bonito_app/dev/Makie/src/Makie.jl:1
in expression starting at stdin:3
Stacktrace:
  [1] pkgerror(msg::String)
    @ Pkg.Types ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/Types.jl:70
  [2] precompile(ctx::Pkg.Types.Context, pkgs::Vector{…}; internal_call::Bool, strict::Bool, warn_loaded::Bool, already_instantiated::Bool, timing::Bool, _from_loading::Bool, kwargs::@Kwargs{})
    @ Pkg.API ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/API.jl:1659
  [3] precompile(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::@Kwargs{_from_loading::Bool})
    @ Pkg.API ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/API.jl:159
  [4] precompile
    @ ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/API.jl:147 [inlined]
  [5] #precompile#114
    @ ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/API.jl:146 [inlined]
  [6] #invokelatest#2
    @ ./essentials.jl:894 [inlined]
  [7] invokelatest
    @ ./essentials.jl:889 [inlined]
  [8] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1963
  [9] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1812
 [10] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
 [11] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [12] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1803
 [13] macro expansion
    @ ./loading.jl:1790 [inlined]
 [14] macro expansion
    @ ./lock.jl:267 [inlined]
 [15] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1753
 [16] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
 [17] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [18] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1746
 [19] eval
    @ ./boot.jl:385 [inlined]
 [20] eval
    @ ./Base.jl:88 [inlined]
 [21] repleval(m::Module, code::Expr, ::String)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.75.2/scripts/packages/VSCodeServer/src/repl.jl:229
 [22] (::VSCodeServer.var"#110#112"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.75.2/scripts/packages/VSCodeServer/src/repl.jl:192
 [23] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging ./logging.jl:515
 [24] with_logger
    @ ./logging.jl:627 [inlined]
 [25] (::VSCodeServer.var"#109#111"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.75.2/scripts/packages/VSCodeServer/src/repl.jl:193
 [26] #invokelatest#2
    @ ./essentials.jl:892 [inlined]
 [27] invokelatest(::Any)
    @ Base ./essentials.jl:889
 [28] (::VSCodeServer.var"#62#63")()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.75.2/scripts/packages/VSCodeServer/src/eval.jl:34
Some type information was truncated. Use `show(err)` to see complete types.

(rqa_bonito_app) pkg> st
Status `~/Documents/rqa_bonito_app/Project.toml`
  [824d6782] Bonito v3.0.6
⌅ [0703355e] DimensionalData v0.24.13
  [411431e0] Extents v0.1.2
  [5789e2e9] FileIO v1.16.2
  [e9467ef8] GLMakie v0.10.0 `dev/Makie/GLMakie`
  [68eda718] GeoFormatTypes v0.4.2
  [db073c08] GeoMakie v0.6.3 `dev/GeoMakie`
  [5c1252a2] GeometryBasics v0.4.10 `https://github.com/JuliaGeometry/GeometryBasics.jl.git#master`
  [c27321d9] Glob v1.3.1
  [ee78f7c6] Makie v0.21.0 `dev/Makie`
  [20f20a25] MakieCore v0.8.0 `dev/Makie/MakieCore`
  [c94c279d] Proj v1.7.0
  [ec211b67] PyramidScheme v0.1.0 `~/Documents/PyramidScheme`
⌃ [a3a2b9e3] Rasters v0.5.1
  [263fe934] TileProviders v0.1.3
  [e170d443] Tyler v0.1.3 `dev/Tyler`
  [c21b50f5] YAXArrays v0.5.4
  [0a941bbe] Zarr v0.9.2
Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated`

@asinghvi17 asinghvi17 mentioned this pull request Mar 19, 2024
@asinghvi17
Copy link
Member Author

asinghvi17 commented May 18, 2024

It looks as though the cover images exist in assets, but they have random filenames (hashes? slugs?) and the HTML still points to the original image paths. @lazarusA have you seen this issue before?

@lazarusA
Copy link
Contributor

lazarusA commented May 18, 2024

yes, when I was trying to do gallery section for BMakie, I had this issue. That's why later I just copy some files to public (no issues there). But, I agree, they should come from assests. Maybe @avik-pal knows better, I don't know how it was done for Lux. Also, those slugs change in every build which makes things harder.

But, then why generated pages work when we save some images to assets and then we just included them in the normal .md file? ....

Edit: Ohh, Lux also has the images in public. :(

@asinghvi17
Copy link
Member Author

asinghvi17 commented May 19, 2024

For pages with assets generated, my guess is that Vitepress picks them up and inlines them.

I guess I can kind of fix that in the code, but all this manual config is not fun...would probably have to save all assets to public. Maybe as a subdir?

@asinghvi17
Copy link
Member Author

So there's a Vitepress package which kind of semi does this? See de1b5c1 (#207). Let's see how the examples turn out!

Comment on lines -21 to +24
onany(Makie.update_axis_camera, camera(scene), scene.transformation.transform_func, finallimits, axis.xreversed, axis.yreversed)
setfield!(scene, :float32convert, Makie.Float32Convert())
onany(scene, scene.transformation.transform_func, finallimits, axis.xreversed, axis.yreversed) do transform_func, finallimits, xreversed, yreversed
Makie.update_axis_camera(scene, transform_func, finallimits, xreversed, yreversed)
Copy link
Member Author

Choose a reason for hiding this comment

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

This may have broken xreversed

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