Skip to content

Commit f4fced1

Browse files
Merge pull request #292 from GSA/fix-translate
Fix translate
2 parents 4fd1207 + 6013dcf commit f4fced1

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

ckanext/geodatagov/logic.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,8 @@ def translate_spatial(old_spatial):
499499
min, max = geometry
500500
params = {"minx": min[0], "miny": min[1], "maxx": max[0], "maxy": max[1]}
501501
new_spatial = geojson_tpl.format(**params)
502+
# assert it is valid JSON
503+
json.loads(new_spatial)
502504
return new_spatial
503505
else:
504506
# If we already have a good geometry, use it

ckanext/geodatagov/tests/test_update_geo.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,13 @@ def test_translations(self):
3232
assert translate_spatial('not exists') is None
3333
assert translate_spatial('1.0,3.0') is None
3434
assert translate_spatial('US, Virginia, Fairfax, Reston') is None
35+
assert translate_spatial(
36+
'["CARTESIAN", [{"WestBoundingCoordinate": -69.864167, "NorthBoundingCoordinate": 70.843889, '
37+
'"EastBoundingCoordinate": -69.864167, "SouthBoundingCoordinate": 70.843889}, '
38+
'{"WestBoundingCoordinate": -68.156667, "NorthBoundingCoordinate": 70.313889, '
39+
'"EastBoundingCoordinate": -68.156667, "SouthBoundingCoordinate": 70.313889}, '
40+
'{"WestBoundingCoordinate": -70.52, "NorthBoundingCoordinate": 69.846667, '
41+
'"EastBoundingCoordinate": -70.52, "SouthBoundingCoordinate": 69.846667}, '
42+
'{"WestBoundingCoordinate": -70.52007, "NorthBoundingCoordinate": 70.843889, '
43+
'"EastBoundingCoordinate": -68.15668, "SouthBoundingCoordinate": 69.84673}]]'
44+
) is None

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
setup(
1212
name="ckanext-geodatagov",
13-
version="0.3.5",
13+
version="0.3.6",
1414
description="",
1515
long_description=long_description,
1616
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)