question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WKTWriter with trim=True and rounding_precision=N misbehaves

See original GitHub issue

Hi,

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:closed
  • Created 5 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
mwtoewscommented, Feb 28, 2021

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.

0reactions
sgilliescommented, Feb 26, 2021

Let’s close this one and reopen if it’s still a problem with GEOS 3.9.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found