Skip to content

Commit

Permalink
Fix error in WKT with integers ending in 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Trigona-Harany committed Aug 18, 2024
1 parent 4ce73c0 commit 13b2ed6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [0.5.3] - 2024-08-18

### Fixed

* Bug in WKTs when there is an integer ending in 0

## [0.5.2] - 2024-08-09

### Changed
Expand Down Expand Up @@ -104,6 +110,7 @@
## [0.0.2] - 2017-08-06
## [0.0.1] - 2017-07-30

[0.5.3]: https://github.com/bosth/plpygis/compare/v0.5.2...v0.5.3
[0.5.2]: https://github.com/bosth/plpygis/compare/v0.5.1...v0.5.2
[0.5.1]: https://github.com/bosth/plpygis/compare/v0.5.0...v0.5.1
[0.5.0]: https://github.com/bosth/plpygis/compare/v0.4.2...v0.5.0
Expand Down
2 changes: 1 addition & 1 deletion plpygis/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.5.2"
__version__ = "0.5.3"
2 changes: 1 addition & 1 deletion plpygis/wkt.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def add(self, text):
self.wkt += text

def format(self, coords):
return " ".join([f"{c}".rstrip("0").rstrip(".") for c in coords])
return " ".join([f"{float(c)}".rstrip("0").rstrip(".") for c in coords])

def wrap(self, text):
return f"({text})"
Expand Down
4 changes: 4 additions & 0 deletions test/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1318,3 +1318,7 @@ def test_wkt_write_linestring():
wkt = "GEOMETRYCOLLECTION (MULTIPOINT ((0 0), (1 1)), POINT (3 4), LINESTRING (2 3, 3 4))"
geom = Geometry.from_wkt(wkt)
assert geom.wkt == wkt

def test_wkt_rounding():
p = Point((1, 1000, 1000.0000, 1.1000))
assert p.wkt == "POINT ZM (1 1000 1000 1.1)"

0 comments on commit 13b2ed6

Please sign in to comment.