• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python net.readNet函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sumolib.net.readNet函数的典型用法代码示例。如果您正苦于以下问题:Python readNet函数的具体用法?Python readNet怎么用?Python readNet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了readNet函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: main

def main(options):
    net = readNet(options.network)
    edges = set([e.getID() for e in net.getEdges()])
    if options.orig_net is not None:
        orig_net = readNet(options.orig_net)
    else:
        orig_net = None
    print("Valid area contains %s edges" % len(edges))

    if options.trips:
        output_type = 'trips'
        writer = write_trip
    else:
        output_type = 'routes'
        writer = write_route

    busStopEdges = {}
    if options.stops_output:
        busStops = codecs.open(options.stops_output, 'w', encoding='utf8')
        busStops.write(
            '<additional xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
            'xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/additional_file.xsd">\n')
    if options.additional_input:
        for busStop in parse(options.additional_input, 'busStop'):
            edge = busStop.lane[:-2]
            busStopEdges[busStop.id] = edge
            if options.stops_output and edge in edges:
                busStops.write(busStop.toXML('    '))
    if options.stops_output:
        busStops.write('</additional>\n')
        busStops.close()

    def write_to_file(vehicles, f):
        f.write('<!-- generated with %s for %s from %s -->\n' %
                (os.path.basename(__file__), options.network, options.routeFiles))
        f.write(
            ('<%s xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
             'xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/routes_file.xsd">\n') % output_type)
        num_routes = 0
        for _, v in vehicles:
            num_routes += 1
            writer(f, v)
        f.write('</%s>\n' % output_type)
        print("Wrote %s %s" % (num_routes, output_type))

    if options.big:
        # write output unsorted
        tmpname = options.output + ".unsorted"
        with codecs.open(tmpname, 'w', encoding='utf8') as f:
            write_to_file(
                cut_routes(edges, orig_net, options, busStopEdges), f)
        # sort out of memory
        sort_routes.main([tmpname, '--big', '--outfile', options.output])
    else:
        routes = list(cut_routes(edges, orig_net, options, busStopEdges))
        routes.sort(key=lambda v: v[0])
        with codecs.open(options.output, 'w', encoding='utf8') as f:
            write_to_file(routes, f)
开发者ID:fieryzig,项目名称:sumo,代码行数:58,代码来源:cutRoutes.py


示例2: main

def main():
    options = get_options()
    net = readNet(options.network)
    edges = set([e.getID() for e in net.getEdges()])
    if options.orig_net is not None:
        orig_net = readNet(options.orig_net)
    else:
        orig_net = None
    print "Valid area contains %s edges" % len(edges)

    if options.trips:
        start_tag = "<trips>"
        end_tag = "</trips>"
        output_type = "trips"
        writer = write_trip
    else:
        start_tag = "<routes>"
        end_tag = "</routes>"
        output_type = "routes"
        writer = write_route

    def write_to_file(routes, f):
        comment = "<!-- generated with %s for %s from %s -->" % (
            os.path.basename(__file__),
            options.network,
            options.routeFiles,
        )
        print >> f, comment
        print >> f, start_tag
        num_routes = 0
        for route in routes:
            num_routes += 1
            writer(f, *route)
        print >> f, end_tag
        print "Wrote %s %s" % (num_routes, output_type)

    if options.big:
        # write output unsorted
        tmpname = options.output + ".unsorted"
        with open(tmpname, "w") as f:
            write_to_file(cut_routes(edges, orig_net, options), f)
        # sort out of memory
        sort_routes.main([tmpname, "--big", "--outfile", options.output])
    else:
        routes = list(cut_routes(edges, orig_net, options))
        routes.sort()
        with open(options.output, "w") as f:
            write_to_file(routes, f)
开发者ID:namnatulco,项目名称:sumo-complete,代码行数:48,代码来源:cutRoutes.py


示例3: run_ere

def run_ere(scenario_name, closed_roads, s_time, duration):
    """
    This is to enable the enroute event scenario using TraCI
    :param scenario_name: the name of the scenario
    :param closed_roads: the list of closed road id
    :param s_time: the starting time stamp for the road closure in seconds
    :param duration: the road closure duration in seconds
    """
    sumo_net = net.readNet(load_map(scenario_name))
    pre_sp_lim = []
    for i in closed_roads:
        pre_sp_lim.append(sumo_net.getEdge(i).getSpeed())

    s_time += traci.simulation.getCurrentTime()/1000
    e_time = s_time + duration

    while traci.simulation.getMinExpectedNumber() > 0:
        cur_step = traci.simulation.getCurrentTime()/1000

        if cur_step == s_time:
            for i in closed_roads:
                traci.edge.setMaxSpeed(i, 0.1)

        if cur_step == e_time:
            for seq, rid in enumerate(closed_roads):
                traci.edge.setMaxSpeed(rid, pre_sp_lim[seq])

        traci.simulationStep()
    traci.close()
    sys.stdout.flush()
开发者ID:ShenWangDCU,项目名称:adanrr,代码行数:30,代码来源:runner.py


示例4: main

def main():
    options = get_options()
    net = readNet(options.network)
    edges = set([e.getID() for e in net.getEdges()])

    lengths1 = {}
    lengths2 = {}
    lengthDiffStats = Statistics(
        "route length difference", histogram=True, scale=options.binwidth)
    for vehicle in parse(options.routeFile1, 'vehicle'):
        lengths1[vehicle.id] = getRouteLength(net, vehicle)
    for vehicle in parse(options.routeFile2, 'vehicle'):
        lengths2[vehicle.id] = getRouteLength(net, vehicle)
        lengthDiffStats.add(
            lengths2[vehicle.id] - lengths1[vehicle.id], vehicle.id)

    print lengthDiffStats

    if options.hist_output is not None:
        with open(options.hist_output, 'w') as f:
            for bin, count in lengthDiffStats.histogram():
                f.write("%s %s\n" % (bin, count))

    if options.full_output is not None:
        with open(options.full_output, 'w') as f:
            differences = sorted(
                [(lengths2[id] - lengths1[id], id) for id in lengths1.keys()])
            for diff, id in differences:
                f.write("%s %s\n" % (diff, id))
开发者ID:sequielo,项目名称:sumo,代码行数:29,代码来源:routeDiffStats.py


示例5: main

def main(args):
    options = parse_args(args)
    net = readNet(options.net)
    known_ids = set()

    def unique_id(cand, index=0):
        cand2 = cand
        if index > 0:
            cand2 = "%s#%s" % (cand, index)
        if cand2 in known_ids:
            return unique_id(cand, index + 1)
        else:
            known_ids.add(cand2)
            return cand2

    with open(options.outfile, 'w') as outf:
        outf.write('<polygons>\n')
        for routefile in options.routefiles:
            print("parsing %s" % routefile)
            if options.standalone:
                for route in parse(routefile, 'route'):
                    # print("found veh", vehicle.id)
                    generate_poly(net, unique_id(route.id), options.colorgen(),
                                  options.layer, options.geo,
                                  route.edges.split(), options.blur, outf)
            else:
                for vehicle in parse(routefile, 'vehicle'):
                    # print("found veh", vehicle.id)
                    generate_poly(net, unique_id(vehicle.id), options.colorgen(),
                                  options.layer, options.geo,
                                  vehicle.route[0].edges.split(), options.blur, outf)
        outf.write('</polygons>\n')
开发者ID:fieryzig,项目名称:sumo,代码行数:32,代码来源:route2poly.py


示例6: __init__

 def __init__(self, cost_attribute, pessimism=0, network_file=None):
     # the cost attribute to parse (i.e. 'traveltime')
     self.cost_attribute = cost_attribute.decode("utf8")
     # the duaIterate iteration index
     self.iteration = None
     # the main data store: for every interval and edge id we store costs and
     # whether data was seen in the last call of load_costs()
     # start -> (edge_id -> EdgeMemory)
     self.intervals = defaultdict(dict)
     # the intervall length (only known for certain if multiple intervals
     # have been seen)
     self.interval_length = 214748  # SUMOTIME_MAXSTRING
     # the intervall currently being parsed
     self.current_interval = None
     # the combined weigth of all previously loaded costs
     self.memory_weight = 0.0
     # update is done according to: memory * memory_factor + new * (1 -
     # memory_factor)
     self.memory_factor = None
     # differences between the previously loaded costs and the memorized
     # costs
     self.errors = None
     # some statistics
     self.num_loaded = 0
     self.num_decayed = 0
     # travel times without obstructing traffic
     # XXX could use the minimum known traveltime
     self.traveltime_free = defaultdict(lambda: 0)
     if network_file is not None:
         # build a map of default weights for decaying edges assuming the
         # attribute is traveltime
         self.traveltime_free = dict(
             [(e.getID(), e.getLength() / e.getSpeed()) for e in readNet(network_file).getEdges()]
         )
     self.pessimism = pessimism
开发者ID:aarongolliver,项目名称:sumo,代码行数:35,代码来源:costMemory.py


示例7: main

def main():
    options = parse_args()
    net = readNet(options.net)
    with open(options.outfile, 'w') as outf:
        outf.write('<polygons>\n')
        for vehicle in parse(options.routefile, 'vehicle'):
            generate_poly(net, vehicle.id, options.colorgen(), options.layer, vehicle.route[0].edges.split(), outf)
        outf.write('</polygons>\n')
开发者ID:cathyyul,项目名称:sumo-0.18,代码行数:8,代码来源:route2poly.py


示例8: main

def main():
    random.seed(42)
    options = parse_args()
    net = readNet(options.net)
    with open(options.outfile, "w") as outf:
        outf.write("<polygons>\n")
        for taz in parse(options.routefile, "taz"):
            generate_poly(net, taz.id, options.colorgen(), options.layer, taz.edges.split(), outf)
        outf.write("</polygons>\n")
开发者ID:702nADOS,项目名称:sumo,代码行数:9,代码来源:districts2poly.py


示例9: main

def main(netFile, outFile, radius, useTravelDist):
    net = readNet(netFile, withConnections=False, withFoes=False)
    with open(outFile, 'w') as outf:
        outf.write('<tazs>\n')
        for taz, edges in computeBidiTaz(net, radius, useTravelDist):
            outf.write('    <taz id="%s" edges="%s"/>\n' % (
                taz.getID(), ' '.join(sorted([e.getID() for e in edges]))))
        outf.write('</tazs>\n')
    return net
开发者ID:sequielo,项目名称:sumo,代码行数:9,代码来源:generateBidiDistricts.py


示例10: __init__

	def __init__(self, netfile):
		self._sumonet = net.readNet(netfile)
		self._intersections=[]
		self._links=[]
		self._linkMap=[]
		
		self._preprocessNet( netfile )
		self._processNet()
		self._postprocessNet()
开发者ID:cscooper,项目名称:URC,代码行数:9,代码来源:Corner.py


示例11: main

def main():
    options = get_options()
    net = None
    attribute_retriever = None
    if options.attribute == "length":
        net = readNet(options.network)

        def attribute_retriever(vehicle):
            return sum([net.getEdge(e).getLength() for e in vehicle.route[0].edges.split()])
    elif options.attribute == "depart":
        def attribute_retriever(vehicle):
            return float(vehicle.depart)
    elif options.attribute == "numEdges":
        def attribute_retriever(vehicle):
            return len(vehicle.route[0].edges.split())
    else:
        sys.exit("Invalid value '%s' for option --attribute" % options.attribute)

    lengths = {}
    lengths2 = {}

    if options.routeFile2 is None:
        # write statistics on a single route file
        stats = Statistics(
            "route %ss" % options.attribute, histogram=True, scale=options.binwidth)

    for vehicle in parse(options.routeFile, 'vehicle'):
        length = attribute_retriever(vehicle)
        if options.routeFile2 is None:
            stats.add(length, vehicle.id)
        lengths[vehicle.id] = length

    if options.routeFile2 is not None:
        # compare route lengths between two files
        stats = Statistics(
            "route %s difference" % options.attribute, histogram=True, scale=options.binwidth)
        for vehicle in parse(options.routeFile2, 'vehicle'):
            lengths2[vehicle.id] = attribute_retriever(vehicle)
            stats.add(lengths2[vehicle.id] - lengths[vehicle.id], vehicle.id)
    print(stats)

    if options.hist_output is not None:
        with open(options.hist_output, 'w') as f:
            for bin, count in stats.histogram():
                f.write("%s %s\n" % (bin, count))

    if options.full_output is not None:
        with open(options.full_output, 'w') as f:
            if options.routeFile2 is None:
                data = [(v, k) for k, v in lengths.items()]
            else:
                data = [(lengths2[id] - lengths[id], id)
                        for id in lengths.keys()]
            for val, id in sorted(data):
                f.write("%s %s\n" % (val, id))
开发者ID:behrisch,项目名称:sumo,代码行数:55,代码来源:routeStats.py


示例12: __init__

    def __init__(self):
        self.conf = config.Config()
        self.conf.readConfig(constants.CONFIG_FILE)
        self._options = self.__getOptions__()
        self.sumo_net = net.readNet(self.conf.network_file)
        self.original_network = nx.DiGraph()

        # check output directory
        if os.path.isdir(self.conf.output_dir) == False:
            print("there is not output directory...")
            os.mkdir(self.conf.output_dir)
            print("create output directory.")
    
        if self.conf.real_net == True:
            netutil.readRealNetwork(self.sumo_net, self.original_network)
        else:
            netutil.readNetwork(self.sumo_net, self.original_network)
开发者ID:gg-uah,项目名称:ParkiNego,代码行数:17,代码来源:simulator.py


示例13: main

def main(options):
    net = readNet(options.network)
    edges = set([e.getID() for e in net.getEdges()])
    print("Valid area contains %s edges" % len(edges))

    def write_to_file(vehicles, f):
        f.write('<!-- generated with %s for %s from %s -->\n' %
                (os.path.basename(__file__), options.network, options.routeFiles))
        f.write(
            ('<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
             'xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/routes_file.xsd">\n'))
        num_trips = 0
        num_persons = 0
        for _, v in vehicles:
            if v.name == 'trip':
                num_trips += 1
            else:
                num_persons += 1
            writer(f, v)
        f.write('</routes>\n')
        if num_persons > 0:
            print("Wrote %s trips and %s persons" % (num_trips, num_persons))
        else:
            print("Wrote %s trips" % (num_trips))

    validTaz = set()
    if options.additional_input:
        for taz in parse(options.additional_input, 'taz'):
            validTaz.add(taz.id)

    if options.big:
        # write output unsorted
        tmpname = options.output + ".unsorted"
        with codecs.open(tmpname, 'w', encoding='utf8') as f:
            write_to_file(
                cut_trips(edges, options, validTaz), f)
        # sort out of memory
        sort_routes.main([tmpname, '--big', '--outfile', options.output])
    else:
        routes = list(cut_trips(edges, options, validTaz))
        routes.sort(key=lambda v: v[0])
        with codecs.open(options.output, 'w', encoding='utf8') as f:
            write_to_file(routes, f)
开发者ID:behrisch,项目名称:sumo,代码行数:43,代码来源:cutTrips.py


示例14: main

def main():
    options = get_options()
    net = readNet(options.network)
    edges = set([e.getID() for e in net.getEdges()])

    lengths = {}
    lengths2 = {}

    for vehicle in parse(options.routeFile, 'vehicle'):
        lengths[vehicle.id] = getRouteLength(net, vehicle)

    if options.routeFile2 is None:
        # write statistics on a single route file
        stats = Statistics(
            "route lengths", histogram=True, scale=options.binwidth)
        for id, length in lengths.items():
            stats.add(length, id)

    else:
        # compare route lengths between two files
        stats = Statistics(
            "route length difference", histogram=True, scale=options.binwidth)
        for vehicle in parse(options.routeFile2, 'vehicle'):
            lengths2[vehicle.id] = getRouteLength(net, vehicle)
            stats.add(lengths2[vehicle.id] - lengths[vehicle.id], vehicle.id)
    print(stats)

    if options.hist_output is not None:
        with open(options.hist_output, 'w') as f:
            for bin, count in stats.histogram():
                f.write("%s %s\n" % (bin, count))

    if options.full_output is not None:
        with open(options.full_output, 'w') as f:
            if options.routeFile2 is None:
                data = [(v, k) for k, v in lengths.items()]
            else:
                data = [(lengths2[id] - lengths[id], id)
                        for id in lengths.keys()]
            for val, id in sorted(data):
                f.write("%s %s\n" % (val, id))
开发者ID:cbrafter,项目名称:sumo,代码行数:41,代码来源:routeStats.py


示例15: main

def main():
    DUAROUTER = sumolib.checkBinary('duarouter')
    options = get_options()
    net = readNet(options.network)

    routeInfos = {}  # id-> RouteInfo
    if options.standalone:
        for route in parse(options.routeFile, 'route'):
            ri = RouteInfo()
            ri.edges = route.edges.split()
            routeInfos[route.id] = ri
    else:
        for vehicle in parse(options.routeFile, 'vehicle'):
            ri = RouteInfo()
            ri.edges = vehicle.route[0].edges.split()
            routeInfos[vehicle.id] = ri

    for rInfo in routeInfos.values():
        rInfo.airDist = euclidean(
            net.getEdge(rInfo.edges[0]).getShape()[0],
            net.getEdge(rInfo.edges[-1]).getShape()[-1])
        rInfo.length = getRouteLength(net, rInfo.edges)
        rInfo.airDistRatio = rInfo.length / rInfo.airDist

    duarouterInput = options.routeFile
    if options.standalone:
        # generate suitable input file for duarouter
        duarouterInput += ".vehRoutes.xml"
        with open(duarouterInput, 'w') as outf:
            outf.write('<routes>\n')
            for rID, rInfo in routeInfos.items():
                outf.write('    <vehicle id="%s" depart="0">\n' % rID)
                outf.write('        <route edges="%s"/>\n' % ' '.join(rInfo.edges))
                outf.write('    </vehicle>\n')
            outf.write('</routes>\n')

    duarouterOutput = options.routeFile + '.rerouted.rou.xml'
    duarouterAltOutput = options.routeFile + '.rerouted.rou.alt.xml'

    subprocess.call([DUAROUTER,
                     '-n', options.network,
                     '-r', duarouterInput,
                     '-o', duarouterOutput,
                     '--no-step-log'])

    for vehicle in parse(duarouterAltOutput, 'vehicle'):
        routeAlts = vehicle.routeDistribution[0].route
        if len(routeAlts) == 1:
            routeInfos[vehicle.id].detour = 0
            routeInfos[vehicle.id].detourRatio = 1
            routeInfos[vehicle.id].shortest_path_distance = routeInfos[vehicle.id].length
        else:
            oldCosts = float(routeAlts[0].cost)
            newCosts = float(routeAlts[1].cost)
            assert(routeAlts[0].edges.split() == routeInfos[vehicle.id].edges)
            routeInfos[vehicle.id].shortest_path_distance = getRouteLength(net, routeAlts[1].edges.split())
            if oldCosts <= newCosts:
                routeInfos[vehicle.id].detour = 0
                routeInfos[vehicle.id].detourRatio = 1
                if oldCosts < newCosts:
                    sys.stderr.write(("Warning: fastest route for '%s' is slower than original route " +
                                      "(old=%s, new=%s). Check vehicle types\n") % (
                                      vehicle.id, oldCosts, newCosts))
            else:
                routeInfos[vehicle.id].detour = oldCosts - newCosts
                routeInfos[vehicle.id].detourRatio = oldCosts / newCosts

    implausible = []
    allRoutesStats = Statistics("overal implausiblity")
    implausibleRoutesStats = Statistics("implausiblity above threshold")
    for rID in sorted(routeInfos.keys()):
        ri = routeInfos[rID]
        ri.implausibility = (options.airdist_ratio_factor * ri.airDistRatio +
                             options.detour_factor * ri.detour +
                             options.detour_ratio_factor * ri.detourRatio +
                             max(0, options.min_dist / ri.shortest_path_distance - 1) +
                             max(0, options.min_air_dist / ri.airDist - 1))
        allRoutesStats.add(ri.implausibility, rID)
        if ri.implausibility > options.threshold:
            implausible.append((ri.implausibility, rID, ri))
            implausibleRoutesStats.add(ri.implausibility, rID)

    # generate restrictions
    if options.restrictions_output is not None:
        with open(options.restrictions_output, 'w') as outf:
            for score, rID, ri in sorted(implausible):
                edges = ri.edges
                if options.odrestrictions and len(edges) > 2:
                    edges = [edges[0], edges[-1]]
                outf.write("0 %s\n" % " ".join(edges))

    if options.ignore_routes is not None:
        numImplausible = len(implausible)
        ignored = set([r.strip() for r in open(options.ignore_routes)])
        implausible = [r for r in implausible if r not in ignored]
        print("Loaded %s routes to ignore. Reducing implausible from %s to %s" % (
            len(ignored), numImplausible, len(implausible)))

    # generate polygons
    polyOutput = options.routeFile + '.implausible.add.xml'
#.........这里部分代码省略.........
开发者ID:fieryzig,项目名称:sumo,代码行数:101,代码来源:implausibleRoutes.py


示例16: __init__

 def __init__(self, netfile, weightfile=None):
     self.net = readNet(netfile)
     self.cost_attribute = 'traveltime'
     self.weightfile = weightfile
     if self.weightfile is not None:
         self.load_weights(self.weightfile)
开发者ID:cbrafter,项目名称:sumo,代码行数:6,代码来源:dijkstra.py


示例17: len

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from sumolib import net
import sys

if __name__ == '__main__':
	if len(sys.argv) < 2:
		print "Usage: " + sys.argv[0] + " <input network file>"
		sys.exit()

	sumo_net = net.readNet(sys.argv[1])
	print_str = "\""

	for i, e in enumerate(sumo_net.getNodes()):
		if i != len(sumo_net.getNodes()) - 1:
			print_str += e.getID() + ","
		else:
			print print_str + e.getID() + "\""
开发者ID:gg-uah,项目名称:ParkiNego,代码行数:18,代码来源:get_all_edge_id.py


示例18: main

def main(options):
    net = readNet(options.network)
    edges = set([e.getID() for e in net.getEdges()])
    if options.orig_net is not None:
        orig_net = readNet(options.orig_net)
    else:
        orig_net = None
    print("Valid area contains %s edges" % len(edges))

    if options.trips:
        output_type = 'trips'
        writer = write_trip
    else:
        output_type = 'routes'
        writer = write_route

    busStopEdges = {}
    if options.stops_output:
        busStops = codecs.open(options.stops_output, 'w', encoding='utf8')
        busStops.write(
            '<additional xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
            'xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/additional_file.xsd">\n')
    if options.additional_input:
        num_busstops = 0
        kept_busstops = 0
        num_taz = 0
        kept_taz = 0
        for busStop in parse(options.additional_input, ('busStop', 'trainStop')):
            num_busstops += 1
            edge = busStop.lane[:-2]
            busStopEdges[busStop.id] = edge
            if options.stops_output and edge in edges:
                kept_busstops += 1
                if busStop.access:
                    busStop.access = [acc for acc in busStop.access if acc.lane[:-2] in edges]
                busStops.write(busStop.toXML('    ').decode('utf8'))
        for taz in parse(options.additional_input, 'taz'):
            num_taz += 1
            taz_edges = [e for e in taz.edges.split() if e in edges]
            if taz_edges:
                taz.edges = " ".join(taz_edges)
                if options.stops_output:
                    kept_taz += 1
                    busStops.write(taz.toXML('    '))
        if num_busstops > 0 and num_taz > 0:
            print("Kept %s of %s busStops and %s of %s tazs" % (
                kept_busstops, num_busstops, kept_taz, num_taz))
        elif num_busstops > 0:
            print("Kept %s of %s busStops" % (
                kept_busstops, num_busstops))
        elif num_taz > 0:
            print("Kept %s of %s tazs" % (
                kept_taz, num_taz))

    if options.stops_output:
        busStops.write('</additional>\n')
        busStops.close()

    def write_to_file(vehicles, f):
        f.write('<!-- generated with %s for %s from %s -->\n' %
                (os.path.basename(__file__), options.network, options.routeFiles))
        f.write(
            ('<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
             'xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/routes_file.xsd">\n'))
        num_routeRefs = 0
        num_vehicles = 0
        for _, v in vehicles:
            if v.name == 'route':
                num_routeRefs += 1
            else:
                num_vehicles += 1
            writer(f, v)
        f.write('</routes>\n')
        if num_routeRefs > 0:
            print("Wrote %s standalone-routes and %s vehicles" % (num_routeRefs, num_vehicles))
        else:
            print("Wrote %s %s" % (num_vehicles, output_type))

    if options.big:
        # write output unsorted
        tmpname = options.output + ".unsorted"
        with codecs.open(tmpname, 'w', encoding='utf8') as f:
            write_to_file(
                cut_routes(edges, orig_net, options, busStopEdges), f)
        # sort out of memory
        sort_routes.main([tmpname, '--big', '--outfile', options.output])
    else:
        routes = list(cut_routes(edges, orig_net, options, busStopEdges))
        routes.sort(key=lambda v: v[0])
        with codecs.open(options.output, 'w', encoding='utf8') as f:
            write_to_file(routes, f)
开发者ID:behrisch,项目名称:sumo,代码行数:91,代码来源:cutRoutes.py



注:本文中的sumolib.net.readNet函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python output.parse函数代码示例发布时间:2022-05-27
下一篇:
Python net.getEdges函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap