GeoInterface.jl
GeoInterface.jl copied to clipboard
Fix printing wrapper geoms
Proposing a fix for this issue where we modify the displayed text for our wrapper geometries. Each geometry can be displayed in "regular" or "compact" form which will influence how much information is shown to the user. This should make things a bit clearer so we don't get spammed with the raw fields that can be hard to follow.
This looks great, thanks! Love the compactification of the elements you have going on there.
One more thing that I'm thinking we should do is to decrease the number of points printed, so that that any geometry fits on one line. Otherwise you get crazy long strings, aka what we have now, which have crashed my terminal a couple times when ultra long geometries are considered (10k points or higher).
Consider something like the following:
screen_nrows, screen_ncols = displaysize(io)
# limit the number of points plotted to
# floor((screen_ncols - currently_used_space - 1 #= triple dot character =#) / length_of_one_point_in_chars)
# add a `...` in between (unicode character) or indicate number of points somehow, as is done in Strings
I will post a more useful prototype sometime later today, but this is the basic concept.
@asinghvi17 I've had a crack at this, is this sort of what you're after? Now we compress geometries with "..." and report the number of sub geometries hidden, e.g.
linestring = GI.LineString(map(_ -> rand(2), 1:10_000))
Gives
LineString{false, false}([[0.6022716265309537, 0.46854202492808894], [0.7698994281922478, 0.5141934816807233], … (9997) … [0.5275211157024845, 0.7022242690985355], [0.09265052455532974, 0.5388384079940159]])
Sorry for the delay! This is next on my list. Should get to it by Wednesday.
Where is this one at? would be nice to merge
I'm using it locally but have a few fixes I need to push. Other than that it's great!
Hey @asinghvi17 , sorry for the delay (been super swamped at work lately) I've updated some of the logic here to be a bit nicer with how we cut down the displayed details with nested geom types (like polygons with linear rings, etc.) so now we cut a bit out of each sub geometry recursively, e.g.
linearring = GI.LinearRing([(1, 2), (3, 4), (5, 6), (1, 2)])
polygon = GI.Polygon([linearring, linearring])
# gives "Polygon{false, false}([LinearRing([(1, 2), … (2) … , (1, 2)]), LinearRing([(1, 2), … (2) … , (1, 2)])])"