def do(self): # first export current net # self.parent.export_netxml(self.sumofilepath) net = self.parent filepath = self.sumofilepath filepath_edges, filepath_nodes, filepath_connections, filepath_tlss = net.export_painxml( filepath=filepath, is_export_tlss=False) cmlbase = 'netconvert --ignore-errors.edge-type'\ + ' --node-files '+filepathlist_to_filepathstring(filepath_nodes)\ + ' --edge-files '+filepathlist_to_filepathstring(filepath_edges)\ + ' --connection-files '+filepathlist_to_filepathstring(filepath_connections)\ #+' --output-file '+filepathlist_to_filepathstring(filepath) print ' cmlbase', cmlbase self.reset_cml(cmlbase) # apply netconvert and reimport # return NetConvertMixin.do(self) self.update_params() cml = self.get_cml() # print 'SumonetImporter.do',cml self.run_cml(cml) if self.status == 'success': print ' Netconvert done.' if os.path.isfile(self.netfilepath): # print ' sumo.net.xml exists, start generation of xml files' # self.parent.import_netxml(self.netfilepath) self.import_tlsxml() # print ' import in sumopy done.' return True else: return False return False
def import_tlsxml(self, is_remove_xmlfiles=False): print 'import_tlsxml' filepath = self.netfilepath net = self.parent rootname = net.get_rootfilename() filepath = net.get_filepath() dirname = os.path.dirname(filepath) # print ' modes.names',self.modes.names cml = 'netconvert'\ + ' --sumo-net-file '+filepathlist_to_filepathstring(filepath)\ + ' --plain-output-prefix '+filepathlist_to_filepathstring(os.path.join(dirname, rootname)) proc = subprocess.Popen(cml, shell=True) print ' run_cml cml=', cml print ' pid = ', proc.pid proc.wait() if not proc.returncode: tlsfilepath = os.path.join(dirname, rootname + '.tll.xml') print ' import_sumotls', tlsfilepath net.import_sumotls_to_net(tlsfilepath, is_remove_xmlfiles=is_remove_xmlfiles) return True else: return False
def import_tlsxml(self, is_remove_xmlfiles=False): print 'import_tlsxml' filepath = self.netfilepath net = self.parent rootname = net.get_rootfilename() filepath = net.get_filepath() dirname = os.path.dirname(filepath) # print ' modes.names',self.modes.names cml = 'netconvert'\ + ' --sumo-net-file '+filepathlist_to_filepathstring(filepath)\ + ' --plain-output-prefix '+filepathlist_to_filepathstring(os.path.join(dirname, rootname)) proc = subprocess.Popen(cml, shell=True) print ' run_cml cml=', cml print ' pid = ', proc.pid proc.wait() if not proc.returncode: tlsfilepath = os.path.join(dirname, rootname+'.tll.xml') print ' import_sumotls', tlsfilepath net.import_sumotls_to_net(tlsfilepath, is_remove_xmlfiles=is_remove_xmlfiles) return True else: return False