fixes issue with identical input CRSs, now asks if users wants to proceed anyway

git-svn-id: http://svn.osgeo.org/qgis/trunk@13152 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
cfarmer 2010-03-23 23:26:23 +00:00
parent 857a7951d2
commit bb9a52a494

View File

@ -65,40 +65,43 @@ class Dialog(QDialog, Ui_Dialog):
destLayer = self.getVectorLayerByName(self.cmbLayer.currentText()) destLayer = self.getVectorLayerByName(self.cmbLayer.currentText())
srsDefine = destLayer.srs() srsDefine = destLayer.srs()
if srsDefine == vLayer.srs(): if srsDefine == vLayer.srs():
QMessageBox.information(self, self.tr("Define current projection"), self.tr("Identical output spatial reference system chosen")) responce = QMessageBox.question(self, self.tr("Define current projection"),
self.tr("Identical output spatial reference system chosen\n\nAre you sure you want to proceed?"),
QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
if responce == QMessageBox.No:
return
provider = vLayer.dataProvider()
self.progressBar.setValue(35)
inPath = provider.dataSourceUri()
inPath = inPath.remove( QRegExp( "\|.*" ) )
self.progressBar.setValue(40)
if inPath.endsWith(".shp"):
inPath = inPath.left(inPath.length() - 4)
self.progressBar.setValue(55)
if not srsDefine.isValid():
QMessageBox.information(self, self.tr("Define current projection"), self.tr("Output spatial reference system is not valid"))
else: else:
provider = vLayer.dataProvider() self.progressBar.setValue(60)
self.progressBar.setValue(35) outputWkt = srsDefine.toWkt()
inPath = provider.dataSourceUri() self.progressBar.setValue(65)
inPath = inPath.remove( QRegExp( "\|.*" ) ) outputFile = QFile( inPath + ".prj" )
self.progressBar.setValue(40) outputFile.open( QIODevice.WriteOnly | QIODevice.Text )
if inPath.endsWith(".shp"): outputPrj = QTextStream( outputFile )
inPath = inPath.left(inPath.length() - 4) outputPrj << outputWkt
self.progressBar.setValue(55) outputPrj.flush()
if not srsDefine.isValid(): outputFile.close()
QMessageBox.information(self, self.tr("Define current projection"), self.tr("Output spatial reference system is not valid")) self.progressBar.setValue(70)
else: checkFile = QFile( inPath + ".qpj" )
self.progressBar.setValue(60) if checkFile.exists():
outputWkt = srsDefine.toWkt() checkFile.open( QIODevice.WriteOnly | QIODevice.Text )
self.progressBar.setValue(65) outputPrj = QTextStream( checkFile )
outputFile = QFile( inPath + ".prj" )
outputFile.open( QIODevice.WriteOnly | QIODevice.Text )
outputPrj = QTextStream( outputFile )
outputPrj << outputWkt outputPrj << outputWkt
outputPrj.flush() outputPrj.flush()
outputFile.close() checkFile.close()
self.progressBar.setValue(70) self.progressBar.setValue(95)
checkFile = QFile( inPath + ".qpj" ) vLayer.setCrs(srsDefine)
if checkFile.exists(): self.progressBar.setValue(100)
checkFile.open( QIODevice.WriteOnly | QIODevice.Text ) QMessageBox.information(self, self.tr("Define current projection"), self.tr("Defined Projection For:\n%1.shp").arg( inPath ) )
outputPrj = QTextStream( checkFile )
outputPrj << outputWkt
outputPrj.flush()
checkFile.close()
self.progressBar.setValue(95)
vLayer.setCrs(srsDefine)
self.progressBar.setValue(100)
QMessageBox.information(self, self.tr("Define current projection"), self.tr("Defined Projection For:\n%1.shp").arg( inPath ) )
self.progressBar.setValue(0) self.progressBar.setValue(0)
def outProjFile(self): def outProjFile(self):