@@ -65,40 +65,43 @@ def accept(self):
6565 destLayer = self .getVectorLayerByName (self .cmbLayer .currentText ())
6666 srsDefine = destLayer .srs ()
6767 if srsDefine == vLayer .srs ():
68- QMessageBox .information (self , self .tr ("Define current projection" ), self .tr ("Identical output spatial reference system chosen" ))
68+ responce = QMessageBox .question (self , self .tr ("Define current projection" ),
69+ self .tr ("Identical output spatial reference system chosen\n \n Are you sure you want to proceed?" ),
70+ QMessageBox .Yes , QMessageBox .No , QMessageBox .NoButton )
71+ if responce == QMessageBox .No :
72+ return
73+ provider = vLayer .dataProvider ()
74+ self .progressBar .setValue (35 )
75+ inPath = provider .dataSourceUri ()
76+ inPath = inPath .remove ( QRegExp ( "\|.*" ) )
77+ self .progressBar .setValue (40 )
78+ if inPath .endsWith (".shp" ):
79+ inPath = inPath .left (inPath .length () - 4 )
80+ self .progressBar .setValue (55 )
81+ if not srsDefine .isValid ():
82+ QMessageBox .information (self , self .tr ("Define current projection" ), self .tr ("Output spatial reference system is not valid" ))
6983 else :
70- provider = vLayer .dataProvider ()
71- self .progressBar .setValue (35 )
72- inPath = provider .dataSourceUri ()
73- inPath = inPath .remove ( QRegExp ( "\|.*" ) )
74- self .progressBar .setValue (40 )
75- if inPath .endsWith (".shp" ):
76- inPath = inPath .left (inPath .length () - 4 )
77- self .progressBar .setValue (55 )
78- if not srsDefine .isValid ():
79- QMessageBox .information (self , self .tr ("Define current projection" ), self .tr ("Output spatial reference system is not valid" ))
80- else :
81- self .progressBar .setValue (60 )
82- outputWkt = srsDefine .toWkt ()
83- self .progressBar .setValue (65 )
84- outputFile = QFile ( inPath + ".prj" )
85- outputFile .open ( QIODevice .WriteOnly | QIODevice .Text )
86- outputPrj = QTextStream ( outputFile )
84+ self .progressBar .setValue (60 )
85+ outputWkt = srsDefine .toWkt ()
86+ self .progressBar .setValue (65 )
87+ outputFile = QFile ( inPath + ".prj" )
88+ outputFile .open ( QIODevice .WriteOnly | QIODevice .Text )
89+ outputPrj = QTextStream ( outputFile )
90+ outputPrj << outputWkt
91+ outputPrj .flush ()
92+ outputFile .close ()
93+ self .progressBar .setValue (70 )
94+ checkFile = QFile ( inPath + ".qpj" )
95+ if checkFile .exists ():
96+ checkFile .open ( QIODevice .WriteOnly | QIODevice .Text )
97+ outputPrj = QTextStream ( checkFile )
8798 outputPrj << outputWkt
8899 outputPrj .flush ()
89- outputFile .close ()
90- self .progressBar .setValue (70 )
91- checkFile = QFile ( inPath + ".qpj" )
92- if checkFile .exists ():
93- checkFile .open ( QIODevice .WriteOnly | QIODevice .Text )
94- outputPrj = QTextStream ( checkFile )
95- outputPrj << outputWkt
96- outputPrj .flush ()
97- checkFile .close ()
98- self .progressBar .setValue (95 )
99- vLayer .setCrs (srsDefine )
100- self .progressBar .setValue (100 )
101- QMessageBox .information (self , self .tr ("Define current projection" ), self .tr ("Defined Projection For:\n %1.shp" ).arg ( inPath ) )
100+ checkFile .close ()
101+ self .progressBar .setValue (95 )
102+ vLayer .setCrs (srsDefine )
103+ self .progressBar .setValue (100 )
104+ QMessageBox .information (self , self .tr ("Define current projection" ), self .tr ("Defined Projection For:\n %1.shp" ).arg ( inPath ) )
102105 self .progressBar .setValue (0 )
103106
104107 def outProjFile (self ):
0 commit comments