Skip to content
Permalink
Browse files

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

before passing to GDAL commands

Fixes #19855
  • Loading branch information
nyalldawson committed Sep 18, 2018
1 parent fb80835 commit e005d6e2b9b84ecaf14a2290b58d7bc927ea3d08
@@ -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', ' ')
@@ -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()

0 comments on commit e005d6e

Please sign in to comment.
You can’t perform that action at this time.