@@ -56,15 +56,15 @@ def __init__(self):
56
56
def initAlgorithm (self , config = None ):
57
57
self .addParameter (QgsProcessingParameterVectorLayer (self .INPUT ,
58
58
self .tr ('Input Layer' ), types = [QgsProcessing .TypeVectorAnyGeometry ]))
59
- self .addParameter (QgsProcessingParameterCrs (self .CRS , 'Output CRS' ))
59
+ self .addParameter (QgsProcessingParameterCrs (self .CRS , 'CRS' ))
60
60
self .addOutput (QgsProcessingOutputVectorLayer (self .INPUT ,
61
61
self .tr ('Layer with projection' )))
62
62
63
63
def name (self ):
64
64
return 'definecurrentprojection'
65
65
66
66
def displayName (self ):
67
- return self .tr ('Define current projection' )
67
+ return self .tr ('Define layer projection' )
68
68
69
69
def flags (self ):
70
70
return super ().flags () | QgsProcessingAlgorithm .FlagNoThreading
@@ -81,15 +81,17 @@ def processAlgorithm(self, parameters, context, feedback):
81
81
if dsPath .lower ().endswith ('.shp' ):
82
82
dsPath = dsPath [:- 4 ]
83
83
84
- wkt = crs .toWkt ()
85
- with open (dsPath + '.prj' , 'w' ) as f :
86
- f .write (wkt )
87
-
88
- qpjFile = dsPath + '.qpj'
89
- if os .path .exists (qpjFile ):
90
- with open (qpjFile , 'w' ) as f :
84
+ wkt = crs .toWkt ()
85
+ with open (dsPath + '.prj' , 'w' ) as f :
91
86
f .write (wkt )
92
87
88
+ qpjFile = dsPath + '.qpj'
89
+ if os .path .exists (qpjFile ):
90
+ with open (qpjFile , 'w' ) as f :
91
+ f .write (wkt )
92
+ else :
93
+ feedback .pushConsoleInfo (tr ("Data source isn't a shapefile, skipping .prj/.qpj creation" ))
94
+
93
95
layer .setCrs (crs )
94
96
layer .triggerRepaint ()
95
97
0 commit comments