コード例 #1
0
from __future__ import absolute_import
from __future__ import print_function

import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import sumolib.net  # noqa
from sumolib.xml import parse  # noqa

if len(sys.argv) < 2:
    print("Usage: " + sys.argv[0] + " <NET> <STOPS>", file=sys.stderr)
    sys.exit()

print("Reading net...")
net = sumolib.net.readNet(sys.argv[1])
stops = sys.argv[2]

print("Writing output...")
with open('pois.add.xml', 'w') as f:
    f.write('<?xml version="1.0"?>\n')
    f.write('<additional>\n')
    for stop in parse(stops, 'busStop'):
        lane = net.getLane(stop.lane)
        pos = (float(stop.startPos) + float(stop.endPos)) / 2
        xypos = sumolib.geomhelper.positionAtShapeOffset(lane.getShape(), pos)
        lon, lat = net.convertXY2LonLat(xypos[0], xypos[1])
        f.write(
            '    <poi id="%s" type="%s" color="1,0,0" layer="100" lon="%s" lat="%s"/>\n'
            % (stop.id, stop.name, lon, lat))
    f.write('</additional>\n')
コード例 #2
0
ファイル: poi_at_stops.py プロジェクト: behrisch/sumo
from __future__ import print_function

import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import sumolib.net  # noqa
from sumolib.xml import parse  # noqa


if len(sys.argv) < 2:
    print("Usage: " + sys.argv[0] + " <NET> <STOPS>", file=sys.stderr)
    sys.exit()

print("Reading net...")
net = sumolib.net.readNet(sys.argv[1])
stops = sys.argv[2]


print("Writing output...")
with open('pois.add.xml', 'w') as f:
    f.write('<?xml version="1.0"?>\n')
    f.write('<additional>\n')
    for stop in parse(stops, 'busStop'):
        lane = net.getLane(stop.lane)
        pos = (float(stop.startPos) + float(stop.endPos)) / 2
        xypos = sumolib.geomhelper.positionAtShapeOffset(lane.getShape(), pos)
        lon, lat = net.convertXY2LonLat(xypos[0], xypos[1])
        f.write('    <poi id="%s" type="%s" color="1,0,0" layer="100" lon="%s" lat="%s"/>\n' % (
            stop.id, stop.name, lon, lat))
    f.write('</additional>\n')