[processing][gdal] Strip newlines from custom proj CRS definitions

before passing to GDAL commands

Fixes #19855
This commit is contained in:
Nyall Dawson 2018-09-18 12:59:01 +10:00
parent fb80835911
commit e005d6e2b9
2 changed files with 9 additions and 2 deletions

View File

@ -447,5 +447,5 @@ class GdalUtils:
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', ' ')

View File

@ -292,6 +292,13 @@ class TestGdalAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsTest):
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()