Skip to content

Commit

Permalink
Fix for #1609
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Gillies committed Feb 1, 2019
1 parent 9117090 commit 63589a4
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Next (?)
instances (#1600) has been fixed (#1610).
- A previously unreported bug preventing BufferedDatasetWriters from being
opened in r+ mode has been fixed.
- A regression in creating CRS objects from PROJ4 strings that include
"+wktext" (#1609) has been fixed.

1.0.15 (2019-01-27)
-------------------
Expand Down
1 change: 1 addition & 0 deletions rasterio/_crs.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ _param_data = """
+vopt
+W
+westo
+wktext
+x_0 False easting
+y_0 False northing
+zone UTM zone
Expand Down
12 changes: 11 additions & 1 deletion rasterio/crs.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,17 @@ def __init__(self, initialdata=None, **kwargs):
if 'init' in data:
data['init'] = data['init'].replace('EPSG:', 'epsg:')

proj = ' '.join(['+{}={}'.format(key, val) for key, val in data.items()])
proj_parts = []

for key, val in data.items():
if val is False or None:
continue
elif val is True:
proj_parts.append('+{}'.format(key))
else:
proj_parts.append('+{}={}'.format(key, val))

proj = ' '.join(proj_parts)
self._crs = _CRS.from_proj4(proj)

else:
Expand Down
30 changes: 30 additions & 0 deletions tests/test_crs.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,33 @@ def test_implicit_proj_dict(projection_string):
def test_capitalized_epsg_init():
"""Ensure that old behavior is preserved"""
assert CRS(init='EPSG:4326').to_epsg() == 4326


def test_issue1609_wktext_a():
"""Check on fix of issue 1609"""
src_proj = {'ellps': 'WGS84',
'proj': 'stere',
'lat_0': -90.0,
'lon_0': 0.0,
'x_0': 0.0,
'y_0': 0.0,
'lat_ts': -70,
'no_defs': True}
wkt = CRS(src_proj).wkt
assert 'PROJECTION["Polar_Stereographic"]' in wkt
assert 'PARAMETER["latitude_of_origin",-70]' in wkt


def test_issue1609_wktext_b():
"""Check on fix of issue 1609"""
dst_proj = {'ellps': 'WGS84',
'h': 9000000.0,
'lat_0': -78.0,
'lon_0': 0.0,
'proj': 'nsper',
'units': 'm',
'x_0': 0,
'y_0': 0,
'wktext': True}
wkt = CRS(dst_proj).wkt
assert 'EXTENSION["PROJ4","+ellps=WGS84 +h=9000000.0 +lat_0=-78.0 +lon_0=0.0 +proj=nsper +units=m +x_0=0 +y_0=0 +wktext"]]' in wkt

0 comments on commit 63589a4

Please sign in to comment.