Skip to content

Commit

Permalink
[processing][gdal] Strip newlines from custom proj CRS definitions
Browse files Browse the repository at this point in the history
before passing to GDAL commands

Fixes #19855
  • Loading branch information
nyalldawson committed Sep 18, 2018
1 parent fb80835 commit e005d6e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/gdal/GdalUtils.py
Expand Up @@ -447,5 +447,5 @@ def gdal_crs_string(crs):
if crs.authid().upper().startswith('EPSG:'):
return crs.authid()

# fallback to proj4 string
return crs.toProj4()
# fallback to proj4 string, stripping out newline characters
return crs.toProj4().replace('\n', ' ').replace('\r', ' ')
7 changes: 7 additions & 0 deletions python/plugins/processing/tests/GdalAlgorithmsTest.py
Expand Up @@ -292,6 +292,13 @@ def testCrsConversion(self):
self.assertTrue(crs.isValid())
self.assertEqual(GdalUtils.gdal_crs_string(crs),
'+proj=utm +zone=36 +south +a=600000 +b=70000 +towgs84=-143,-90,-294,0,0,0,0 +units=m +no_defs')
# check that newlines are stripped
crs = QgsCoordinateReferenceSystem()
crs.createFromProj4(
'+proj=utm +zone=36 +south\n +a=600000 +b=70000 \r\n +towgs84=-143,-90,-294,0,0,0,0 +units=m\n+no_defs')
self.assertTrue(crs.isValid())
self.assertEqual(GdalUtils.gdal_crs_string(crs),
'+proj=utm +zone=36 +south +a=600000 +b=70000 +towgs84=-143,-90,-294,0,0,0,0 +units=m +no_defs')

def testAssignProjection(self):
context = QgsProcessingContext()
Expand Down

0 comments on commit e005d6e

Please sign in to comment.