Пример #1
0
def route(tripfilepath,
          netfilepath,
          routefilepath,
          options='-v --ignore-errors'):
    #  do not use options: --repair --remove-loops
    cmd = 'duarouter '+options+' --trip-files %s --net-file %s --output-file %s'\
            %(  ff(tripfilepath), ff(netfilepath),ff(routefilepath))
    return call(cmd)
Пример #2
0
def duaroute(tripfilepath, netfilepath, routefilepath, options='-v --ignore-errors'):
    """
    Simple shortes path duaoute function
    """
    #  do not use options: --repair --remove-loops
    cmd = 'duarouter '+options+' --trip-files %s --net-file %s --output-file %s'\
        % (ff(tripfilepath), ff(netfilepath), ff(routefilepath))
    return call(cmd)
Пример #3
0
    def do(self):
        cml = self.get_cml()
        scenario = self.parent

        ## exports, if required
        if self.is_export_net:
            ptstopsfilepath = scenario.net.ptstops.export_sumoxml(
                self.ptstopsfilepath)
            scenario.net.export_netxml(self.netfilepath)
        else:
            ptstopsfilepath = self.ptstopsfilepath

        if self.is_export_flow & (self.flowfilepath.count(',') == 0):
            scenario.demand.odintervals.export_amitranxml(self.flowfilepath)

        # routefiles are only used to specify vtypes
        routefilepath = scenario.demand.trips.get_routefilepath()
        scenario.demand.vtypes.export_xml(routefilepath)

        zonefilepath = scenario.landuse.zones.export_sumoxml()

        rootname = scenario.get_rootfilename()
        rootdirpath = scenario.get_workdirpath()

        self.routeoutputfilepath = os.path.join(rootdirpath,
                                                rootname + '.out.mrflow.xml')
        self.flowoutputfilepath = os.path.join(rootdirpath,
                                               rootname + '.out.mrload.xml')

        cml +=  ' --net-file %s'%(ff(self.netfilepath))+\
                ' --route-files %s'%(ff(routefilepath))+\
                ' --od-amitran-files %s'%(filepathlist_to_filepathstring(self.flowfilepath))+\
                ' --output-file %s'%(ff(self.routeoutputfilepath))+\
                ' --netload-output %s'%(ff(self.flowoutputfilepath))

        additionalpaths = [
            zonefilepath,
        ]
        if os.path.isfile(self.ptstopsfilepath):
            additionalpaths.append(self.ptstopsfilepath)

        cml += ' --additional-files %s' % (
            filepathlist_to_filepathstring(additionalpaths))

        if self.logfilepath != '':
            cml += ' --log %s' % (ff(self.logfilepath))

        #print '\n Starting command:',cml
        if call(cml):
            if os.path.isfile(self.flowoutputfilepath):
                #self.parent.import_routes_xml(routefilepath)
                #os.remove(routefilepath)
                return True
            else:
                return False
        else:
            return False
Пример #4
0
def duaroute(tripfilepath,
             netfilepath,
             routefilepath,
             weightfilepath=None,
             weightattribute='traveltime',
             options='-v --ignore-errors'):
    """
    Simple shortes path duaoute function
    """
    #  do not use options: --repair --remove-loops
    cmd = 'duarouter '+options+' --route-files %s --net-file %s --output-file %s'\
            %(  ff(tripfilepath), ff(netfilepath),ff(routefilepath))

    if weightfilepath is not None:
        cmd += " --weight-files %s --weight-attribute %s" % (
            ff(weightfilepath), weightattribute)

    return call(cmd)