Skip to content

Commit 745857b

Browse files
committed
return true coordinate precision
1 parent 8778f50 commit 745857b

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

pycsw/core/util.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,13 @@ def bbox2wktpolygon(bbox):
240240
241241
"""
242242

243-
precision = int(os.environ.get('COORDINATE_PRECISION', 2))
244243
if bbox.startswith('ENVELOPE'):
245244
bbox = wktenvelope2bbox(bbox)
246-
minx, miny, maxx, maxy = [f"{float(coord):.{precision}f}" for coord in bbox.split(",")]
247-
wktGeometry = 'POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))' \
245+
246+
minx, miny, maxx, maxy = [float(coord) for coord in bbox.split(",")]
247+
248+
return 'POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))' \
248249
% (minx, miny, minx, maxy, maxx, maxy, maxx, miny, minx, miny)
249-
return wktGeometry
250250

251251

252252
def transform_mappings(queryables, typename):

tests/unittests/test_util.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,20 @@ def test_wkt2geom(wkt, bounds, expected):
141141
@pytest.mark.parametrize("bbox, expected", [
142142
(
143143
"0.0, 10.0, 30.0, 15.0",
144-
"POLYGON((0.00 10.00, 0.00 15.00, 30.00 15.00, "
145-
"30.00 10.00, 0.00 10.00))"
144+
"POLYGON((0.0 10.0, 0.0 15.0, 30.0 15.0, "
145+
"30.0 10.0, 0.0 10.0))"
146146
),
147147
(
148148
"-10.0, 10.0, 30.0, 15.0",
149-
"POLYGON((-10.00 10.00, -10.00 15.00, 30.00 15.00, "
150-
"30.00 10.00, -10.00 10.00))"
149+
"POLYGON((-10.0 10.0, -10.0 15.0, 30.0 15.0, "
150+
"30.0 10.0, -10.0 10.0))"
151151
),
152+
(
153+
"25.0815883093, 62.1306897126, 27.1935425597, 63.129387237",
154+
"POLYGON((25.0815883093 62.1306897126, 25.0815883093 63.129387237, "
155+
"27.1935425597 63.129387237, 27.1935425597 62.1306897126, "
156+
"25.0815883093 62.1306897126))"
157+
)
152158
])
153159
def test_bbox2wktpolygon(bbox, expected):
154160
result = util.bbox2wktpolygon(bbox)
@@ -367,6 +373,7 @@ def test_programmatic_import_with_invalid_path(invalid_import_path):
367373
result = util.programmatic_import(invalid_import_path)
368374
assert result is None
369375

376+
370377
def test_sanitize_url():
371378
result = util.sanitize_db_connect("postgresql://username:password@localhost/pycsw")
372379
assert result == "postgresql://***:***@localhost/pycsw"

0 commit comments

Comments
 (0)