def on_button_try_clicked(self, widget, data=None): print self.ui.entry1.get_text() proj = self.ui.entry1.get_text() if proj != '': #Reproject Previewdata if tester == False: command = 'ogr2ogr -f \'ESRI Shapefile\' ./data/media/cache/reprojected' + str( counter ) + ' ./data/media/ne_110m_admin_0_countries.shp -t_srs \'' + proj + '\' -overwrite -skipfailure' imagefile = "./data/media/new_world_style_tryNerror.png" command2 = 'rm -r ./data/media/cache/reprojected' + str( counter) else: home = os.getenv("HOME") folder = home + '/maproj/media' command = 'ogr2ogr -f \'ESRI Shapefile\' ' + folder + '/cache/reprojected' + str( counter ) + ' /usr/share/maproj/media/ne_110m_admin_0_countries.shp -t_srs \'' + proj + '\' -overwrite -skipfailure' imagefile = folder + "/new_world_style_tryNerror.png" command2 = 'rm -r ' + folder + '/cache/reprojected' + str( counter) os.system(command) #Make XML-file with chosen projection stylefile = "world_style_tryNerror.xml" new_stylefile = t.replaceProjection('./data/media', stylefile, proj, counter, tester) #Render preview try: #start rendering image = t.run(imagefile, new_stylefile) #show rendered preview self.ui.image1.set_from_file(image) self.ui.label_feedback.set_text('Yes...that works!') except: self.ui.image1.clear() self.ui.label_feedback.set_text('Oh no...that doesn\'t work!') #clear cache os.system(command2) #increment counter global counter counter = counter + 1 else: self.ui.label_feedback.set_text('Nothing entered!')
def on_comboboxtext1_changed(self, widget, data=None): #get the chosen projection global name name = self.ui.comboboxtext1.get_active_text() proj = '' proj = dict1[str(name)] self.ui.entry2.set_text(dict1[str( self.ui.comboboxtext1.get_active_text())]) if proj != 'None': #Reproject Previewdata global tester if tester == False: folder = './data/media' command = 'ogr2ogr -f \'ESRI Shapefile\' ' + folder + '/cache/reprojected' + str( counter ) + ' ./data/media/ne_110m_admin_0_countries.shp -t_srs \'' + proj + '\' -overwrite -skipfailure' else: #needs another saving place ---this one has no rights to write folder = home + '/maproj/media' command = 'ogr2ogr -f \'ESRI Shapefile\' ' + folder + '/cache/reprojected' + str( counter ) + ' /usr/share/maproj/media/ne_110m_admin_0_countries.shp -t_srs \'' + proj + '\' -overwrite -skipfailure' os.system(command) #os.system('ogrinfo -al ./data/media/reprojected0/ne_110m_admin_0_countries.shp') #self.ui.entry1.set_text("Previewdata was reprojected") #Make XML-file with chosen projection #*** stylefile = "world_style.xml" new_stylefile = t.replaceProjection(folder, stylefile, proj, counter, tester) #self.ui.entry1.set_text("XML was rewritten") #Render preview global imagefile imagefile = folder + "/new_world_style.png" #start rendering image = t.run(imagefile, new_stylefile) #show rendered preview self.ui.image1.set_from_file(image) #self.ui.entry1.set_text("Preview was rendered") #clear cache command2 = 'rm -r ' + folder + '/cache/reprojected' + str(counter) os.system(command2) #increment counter global counter counter = counter + 1
def on_comboboxtext1_changed(self, widget, data=None): #get the chosen projection global name name = self.ui.comboboxtext1.get_active_text() proj = '' proj = dict1[str(name)] self.ui.entry2.set_text(dict1[str(self.ui.comboboxtext1.get_active_text())]) if proj != 'None': #Reproject Previewdata global tester if tester == False: folder = './data/media' command = 'ogr2ogr -f \'ESRI Shapefile\' '+folder+'/cache/reprojected'+str(counter)+' ./data/media/ne_110m_admin_0_countries.shp -t_srs \''+proj+'\' -overwrite -skipfailure' else: #needs another saving place ---this one has no rights to write folder = home + '/maproj/media' command = 'ogr2ogr -f \'ESRI Shapefile\' '+folder+'/cache/reprojected'+str(counter)+' /usr/share/maproj/media/ne_110m_admin_0_countries.shp -t_srs \''+proj+'\' -overwrite -skipfailure' os.system(command) #os.system('ogrinfo -al ./data/media/reprojected0/ne_110m_admin_0_countries.shp') #self.ui.entry1.set_text("Previewdata was reprojected") #Make XML-file with chosen projection #*** stylefile = "world_style.xml" new_stylefile = t.replaceProjection(folder,stylefile,proj,counter,tester) #self.ui.entry1.set_text("XML was rewritten") #Render preview global imagefile imagefile = folder + "/new_world_style.png" #start rendering image = t.run(imagefile, new_stylefile) #show rendered preview self.ui.image1.set_from_file(image) #self.ui.entry1.set_text("Preview was rendered") #clear cache command2 = 'rm -r '+folder+'/cache/reprojected'+str(counter) os.system(command2) #increment counter global counter counter = counter + 1
def on_button_try_clicked(self, widget, data=None): print self.ui.entry1.get_text() proj = self.ui.entry1.get_text() if proj != '': #Reproject Previewdata if tester == False: command = 'ogr2ogr -f \'ESRI Shapefile\' ./data/media/cache/reprojected'+str(counter)+' ./data/media/ne_110m_admin_0_countries.shp -t_srs \''+proj+'\' -overwrite -skipfailure' imagefile = "./data/media/new_world_style_tryNerror.png" command2 = 'rm -r ./data/media/cache/reprojected'+str(counter) else: home = os.getenv("HOME") folder = home + '/maproj/media' command = 'ogr2ogr -f \'ESRI Shapefile\' '+folder+'/cache/reprojected'+str(counter)+' /usr/share/maproj/media/ne_110m_admin_0_countries.shp -t_srs \''+proj+'\' -overwrite -skipfailure' imagefile = folder + "/new_world_style_tryNerror.png" command2 = 'rm -r '+ folder +'/cache/reprojected'+str(counter) os.system(command) #Make XML-file with chosen projection stylefile = "world_style_tryNerror.xml" new_stylefile = t.replaceProjection('./data/media',stylefile,proj,counter, tester) #Render preview try: #start rendering image = t.run(imagefile, new_stylefile) #show rendered preview self.ui.image1.set_from_file(image) self.ui.label_feedback.set_text('Yes...that works!') except: self.ui.image1.clear() self.ui.label_feedback.set_text('Oh no...that doesn\'t work!') #clear cache os.system(command2) #increment counter global counter counter = counter + 1 else: self.ui.label_feedback.set_text('Nothing entered!')