Skip to content

Commit e005d6e

Browse files
committedSep 18, 2018
[processing][gdal] Strip newlines from custom proj CRS definitions
before passing to GDAL commands Fixes #19855
1 parent fb80835 commit e005d6e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed
 

‎python/plugins/processing/algs/gdal/GdalUtils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,5 +447,5 @@ def gdal_crs_string(crs):
447447
if crs.authid().upper().startswith('EPSG:'):
448448
return crs.authid()
449449

450-
# fallback to proj4 string
451-
return crs.toProj4()
450+
# fallback to proj4 string, stripping out newline characters
451+
return crs.toProj4().replace('\n', ' ').replace('\r', ' ')

‎python/plugins/processing/tests/GdalAlgorithmsTest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,13 @@ def testCrsConversion(self):
292292
self.assertTrue(crs.isValid())
293293
self.assertEqual(GdalUtils.gdal_crs_string(crs),
294294
'+proj=utm +zone=36 +south +a=600000 +b=70000 +towgs84=-143,-90,-294,0,0,0,0 +units=m +no_defs')
295+
# check that newlines are stripped
296+
crs = QgsCoordinateReferenceSystem()
297+
crs.createFromProj4(
298+
'+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')
299+
self.assertTrue(crs.isValid())
300+
self.assertEqual(GdalUtils.gdal_crs_string(crs),
301+
'+proj=utm +zone=36 +south +a=600000 +b=70000 +towgs84=-143,-90,-294,0,0,0,0 +units=m +no_defs')
295302

296303
def testAssignProjection(self):
297304
context = QgsProcessingContext()

0 commit comments

Comments
 (0)
Please sign in to comment.