GeoInterface.jl icon indicating copy to clipboard operation
GeoInterface.jl copied to clipboard

Fix printing wrapper geoms

Open BenCurran98 opened this issue 1 year ago • 5 comments

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.

BenCurran98 avatar Jul 25 '24 21:07 BenCurran98

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 avatar Jul 26 '24 04:07 asinghvi17

@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]])

BenCurran98 avatar Aug 02 '24 05:08 BenCurran98

Sorry for the delay! This is next on my list. Should get to it by Wednesday.

asinghvi17 avatar Sep 02 '24 15:09 asinghvi17

Where is this one at? would be nice to merge

rafaqz avatar Sep 25 '24 21:09 rafaqz

I'm using it locally but have a few fixes I need to push. Other than that it's great!

asinghvi17 avatar Sep 25 '24 21:09 asinghvi17

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)])])"

BenCurran98 avatar Nov 04 '24 02:11 BenCurran98