コード例 #1
0
ファイル: WPSWindow.py プロジェクト: RaKl/TileGen
 def writeResultToDB(self, results, table_name):
     
     postgreFunctions.makePostgresTable(table_name)
     real_results = []
     print 'Begin Writing'
     for result in results:
         if result[0] != '':
             start_time = time.time()
             #real_results.append(result)
             postgreFunctions.writeToPostgres(result[0], table_name)
             final_time = round(time.time()-start_time, 3)
             av = round(result[1]/final_time,3)
             self.params.writeToLog('Wrote %s with %s %s(s) to DB - it took:%s seconds! --> ca. %s /sec'%(result[0], str(result[1]), str(result[2]), str(final_time), str(av)))
     print 'Done writing'
コード例 #2
0
    def writeResultToDB(self, results, table_name):

        postgreFunctions.makePostgresTable(table_name)
        real_results = []
        print 'Begin Writing'
        for result in results:
            if result[0] != '':
                start_time = time.time()
                #real_results.append(result)
                postgreFunctions.writeToPostgres(result[0], table_name)
                final_time = round(time.time() - start_time, 3)
                av = round(result[1] / final_time, 3)
                self.params.writeToLog(
                    'Wrote %s with %s %s(s) to DB - it took:%s seconds! --> ca. %s /sec'
                    % (result[0], str(result[1]), str(
                        result[2]), str(final_time), str(av)))
        print 'Done writing'
コード例 #3
0
ファイル: TilesDialog.py プロジェクト: RaKl/TileGen
 def on_button_generalize_clicked(self, widget, data=None):
     if self.ui.comboboxtext_rules.get_active() != -1:
         start = time.time()
         #new_object.setButtonLabel(False)     
         
         tileBunch = new_object.getTileBunch(zentral_tile)
         self.tileproj = rendering.GoogleProjection(maxZoom+1)
         
         extentBunch = []
         
         text = self.ui.label_params.get_text()
         lines = text.split('\n')
         params = []
         for i in range(2,len(lines)):
                 text = lines[i].split(' - ')
                #print text
                 text2 = text[1].split(':')
                #print text2
                 params.append((text[0].replace('- ',''),text2[0].replace('(','').replace(')',''),text2[1]))
        #print params
         
         for tile in tileBunch:
             infos = []
             #infos of the tile that should be processed
             extent, z = new_object.getExtents(tile)
             infos.append(extent)
             #infos for the creation of the valid xml-wps file
             source = self.datasource[2]['file']#"/home/klammer/Software/Quickly/tilegen/data/media/testdaten/mercator_polygon/linesvgtl270112.shp"
             func_ident = self.chosen_identifier#'ch.unizh.geo.webgen.service.LineSmoothing'
             infos.append(source)
             infos.append(func_ident)
             #informations for sending the valid xml-wps file to the server
             server = self.ui.entry_server.get_text()
             dest_file = "WebGen_WPS_"+str(tile[0])+"_"+str(tile[1])+"_"+str(z)+".xml"
             xml_files_folder = generalHome + 'xmlfiles/'
             if not os.path.isdir(xml_files_folder):
                 os.mkdir(xml_files_folder)
     
             #folder = "/home/klammer/Software/Quickly/tilegen/data/media/cache/xmlfiles/"
             infos.append(server)
             infos.append(dest_file)
             infos.append(xml_files_folder)
             chosen_filter = str(self.filter)
             infos.append(chosen_filter)
             infos.append(params)
             infos.append(tile)
             infos.append(logs)
             #store all infos in an array, so it is possible to give that array to the multiprocessing-pool (that just takes one variable)
             extentBunch.append(infos)
             
         func.writeToLog('Initiated WPS-Execute-Filecreation with...\n\t...server: %s \n\t...filter: %s \n\t...function: %s \n\t...parameters: %s' %(server, str(chosen_filter), str(func_ident), str(params)),logs)
         pool = Pool(processes = 9)        
         results = pool.map(rendering.doWPSProcess, extentBunch)
        #print results
         
         #new_object.setButtonLabel(True)
         
         print 'Done!'
         
         postgre.makePostgresTable()
         real_results = []
         for result in results:
             if result != '':
                 #real_results.append(result)
                 postgre.writeToPostgres(result)
                 print 'Writing'
         print 'Done writing'
             
         #pool = Pool(processes = 9)        
         #pool.map(postgre.writeToPostgres, real_results)
         
         self.ui.button_showGen.set_label('Use generalized\ngeometries')
     else:
         self.ui.label_status.set_text('Please choose a geometry that should be generalized!')