Support rounding for `.wkt_string()`
Hi! A feature I'd really like is supporting rounding to X decimal places in the .wkt_string() function.
For example I can force the output to be POINT (2.32 5.45).
Maybe a second function like wkt_string_rounded(prec: i32)?
I'm happy to work on this myself and PR but wanted to check if this would be something of interest first that would get merged in! Thanks!
Note that this can turn valid polygons into invalid ones (with self-intersections). As prior art, PostGIS has a maxdecimaldigits parameter, but suggets using ST_ReducePrecision first, which calls GEOSGeom_setPrecision.
Another option could be a builder pattern:
wkt::Formatter::new()
.with_pretty_print()
.with_max_decimal_digits(5)
.format(my_wkt)
@lnicola Yes, I see the problem with just rounding naively, has georust already implemented something like ST_ReducePrecision? I haven't been able to find it yet if it has
@frewsxcv I think a builder is actually a much more sensible idea for this interface!
@lnicola Yes, I see the problem with just rounding naively, has georust already implemented something like
ST_ReducePrecision? I haven't been able to find it yet if it has
No, and my understanding is that its implementation is non-trivial so it's unlikely to be available in the short term (but PRs are very welcome)