WKTWriter with trim=True and rounding_precision=N misbehaves
See original GitHub issueHi,
I might discovered a suspicious behavior of the WKTWriter.
I did test with the following Point:
from shapely.wkt import dumps
from shapely.geometry import Point
p = Point(527626.9300000001, 0.00)
“dumps” the point with the “trim=True” should remove trailing zeros (it happens).
print(dumps(p, trim=True))
POINT (527626.9300000001 0)
“dumps” the point with the “rounding_precision=4” round the point to 4 decimal places. In this case it removes 000001 from X coordinate and adds 00 to Y coordinate (it happens).
print(dumps(p, rounding_precision=4))
POINT (527626.9300 0.0000)
The potential error happens when both trim=True" and “rounding_precision=4” are applied to the point. It seems to me that the coordinates are converted to a scientific notation on which the rounding_precision is applied.
print(dumps(p, trim=True, rounding_precision=4))
POINT (5.276e+05 0)
I did tests on both Windows and Linux operating systems.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
WKTWriter with trim=True and rounding_precision=N ... - GitHub
Hi, I might discovered a suspicious behavior of the WKTWriter. ... WKTWriter with trim=True and rounding_precision=N misbehaves #586.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
FYI, this may potentially change with GEOS 3.10 (or current master), which uses Ryū (via https://github.com/libgeos/geos/commit/2376cd6bf5d0743b02b588af17d2e9067c1874de) for string formatting/rounding stuff.
Let’s close this one and reopen if it’s still a problem with GEOS 3.9.