diff --git a/src/abstractgeotable.jl b/src/abstractgeotable.jl index 158b21e..ffc424f 100644 --- a/src/abstractgeotable.jl +++ b/src/abstractgeotable.jl @@ -345,9 +345,26 @@ end Base.show(io::IO, geotable::AbstractGeoTable) = summary(io, geotable) function Base.show(io::IO, ::MIME"text/plain", geotable::AbstractGeoTable) - summary(io, geotable) - println(io) + pretty_table( + io, + geotable; + backend=Val(:text), + _common_kwargs(geotable)..., + newline_at_end=false, + header_crayon=crayon"bold (0,128,128)" + ) +end + +function Base.show(io::IO, ::MIME"text/html", geotable::AbstractGeoTable) + pretty_table( + io, + geotable; + backend=Val(:html), + _common_kwargs(geotable)... + ) +end +function _common_kwargs(geotable) dom = domain(geotable) tab = values(geotable) cols = Tables.columns(tab) @@ -377,24 +394,5 @@ function Base.show(io::IO, ::MIME"text/plain", geotable::AbstractGeoTable) types = first.(tuples) units = last.(tuples) - # print etable - pretty_table( - io, - geotable; - header=(colnames, types, units), - vcrop_mode=:middle, - max_num_of_rows=20, - newline_at_end=false, - header_crayon=crayon"bold (0,128,128)" - ) - - # info about other tables - rank = paramdim(dom) - if rank > 0 - others = filter(r -> !isnothing(values(geotable, r)), 0:(rank - 1)) - if !isempty(others) - println(io) - print(io, "Additional tables encountered for the following ranks: $(join(others, " ,"))") - end - end + (title=summary(geotable), header=(colnames, types, units), vcrop_mode=:middle, max_num_of_rows=20) end diff --git a/test/runtests.jl b/test/runtests.jl index c3242ab..82239f3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -343,8 +343,7 @@ dummymeta(domain, table) = GeoTable(domain, Dict(paramdim(domain) => table)) │ 2 │ 0.11 │ txt7 │ Quadrangle(Point(0.0, 2.0), Point(1.0, 2.0), Point(1.0, 3.0), Point(0.0, 3.0)) │ │ 2 │ 0.64 │ txt8 │ Quadrangle(Point(1.0, 2.0), Point(2.0, 2.0), Point(2.0, 3.0), Point(1.0, 3.0)) │ │ 8 │ 8.46 │ txt9 │ Quadrangle(Point(2.0, 2.0), Point(3.0, 2.0), Point(3.0, 3.0), Point(2.0, 3.0)) │ - └─────────┴────────────┴─────────┴────────────────────────────────────────────────────────────────────────────────┘ - Additional tables encountered for the following ranks: 0""" + └─────────┴────────────┴─────────┴────────────────────────────────────────────────────────────────────────────────┘""" gtb = georef((a=[missing; a[2:9]], b=[b[1:4]; missing; b[6:9]], c=[c[1:8]; missing]), pset) @test sprint(show, gtb) == "9×4 GeoTable over 9 PointSet{2,Float64}" @@ -365,6 +364,89 @@ dummymeta(domain, table) = GeoTable(domain, Dict(paramdim(domain) => table)) │ 2 │ 0.64 │ txt8 │ Point(8.0, 8.0) │ │ 8 │ 8.46 │ missing │ Point(9.0, 9.0) │ └─────────┴────────────┴─────────┴─────────────────┘""" + + gtb = georef((; a, b, c), pset) + @test sprint(show, MIME("text/html"), gtb) == """ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
9×4 GeoTable over 9 PointSet{2,Float64}
abcgeometry
CountContinuousTextualPoint2
NoUnitsNoUnitsNoUnits
02.34txt1Point(1.0, 1.0)
67.5txt2Point(2.0, 2.0)
60.06txt3Point(3.0, 3.0)
31.29txt4Point(4.0, 4.0)
93.64txt5Point(5.0, 5.0)
58.05txt6Point(6.0, 6.0)
20.11txt7Point(7.0, 7.0)
20.64txt8Point(8.0, 8.0)
88.46txt9Point(9.0, 9.0)
+ """ end end end