Skip to content

Commit

Permalink
fix: set precision of coordinates from config
Browse files Browse the repository at this point in the history
  • Loading branch information
netanelC authored and tomkralidis committed Dec 22, 2023
1 parent a126d62 commit 1b26601
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pycsw/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,13 @@ def bbox2wktpolygon(bbox):
"""

precision = int(os.environ.get('COORDINATE_PRECISION', 2))
if bbox.startswith('ENVELOPE'):
bbox = wktenvelope2bbox(bbox)
minx, miny, maxx, maxy = [float(coord) for coord in bbox.split(",")]
return 'POLYGON((%.2f %.2f, %.2f %.2f, %.2f %.2f, %.2f %.2f, %.2f %.2f))' \
minx, miny, maxx, maxy = [f"{float(coord):.{precision}f}" for coord in bbox.split(",")]
wktGeometry = 'POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))' \
% (minx, miny, minx, maxy, maxx, maxy, maxx, miny, minx, miny)
return wktGeometry


def transform_mappings(queryables, typename):
Expand Down

0 comments on commit 1b26601

Please sign in to comment.