本文整理汇总了Python中graphserver.core.WalkOptions.transfer_slack方法的典型用法代码示例。如果您正苦于以下问题:Python WalkOptions.transfer_slack方法的具体用法?Python WalkOptions.transfer_slack怎么用?Python WalkOptions.transfer_slack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graphserver.core.WalkOptions
的用法示例。
在下文中一共展示了WalkOptions.transfer_slack方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GTFSDatabase
# 需要导入模块: from graphserver.core import WalkOptions [as 别名]
# 或者: from graphserver.core.WalkOptions import transfer_slack [as 别名]
gtfsdb = GTFSDatabase ('./trimet.gtfsdb')
gdb = GraphDatabase ('./test.gdb' )
osmdb = OSMDB ('./testgrid.osmdb' )
g = gdb.incarnate ()
# FOOT - would be better if i could specify 0 boardings not 0 transfers
wo = WalkOptions()
wo.max_walk = 2000
wo.walking_overage = 0.0
wo.walking_speed = 1.0 # trimet uses 0.03 miles / 1 minute - but it uses straight line distance as well
wo.transfer_penalty = 99999
wo.walking_reluctance = 1
wo.max_transfers = 0
# make much higher?
wo.transfer_slack = 60 * 5
wo_foot = wo
# TRANSIT
wo = WalkOptions()
wo.max_walk = 2000
wo.walking_overage = 0.0
wo.walking_speed = 1.0 # trimet uses 0.03 miles / 1 minute - but it uses straight line distance as well
wo.transfer_penalty = 60 * 10
wo.walking_reluctance = 1.5
wo.max_transfers = 5
wo.transfer_slack = 60 * 4
wo_transit = wo
print "Fetching grid from OSMDB..."
grid = list(osmdb.execute("SELECT x, y, vertex FROM grid"))
示例2: run
# 需要导入模块: from graphserver.core import WalkOptions [as 别名]
# 或者: from graphserver.core.WalkOptions import transfer_slack [as 别名]
def run(self):
self.gtfsdb = GTFSDatabase(self.gtfsdb)
self.gdb = GraphDatabase(self.gdb)
# Calculate an origin-destination matrix for the graph's stations
print "Loading Graphserver DB..."
self.emit(QtCore.SIGNAL("say(QString)"), QtCore.QString("Loading SQLite Graphserver graph..."))
g = self.gdb.incarnate()
# Set up distance-preserving projection system
# Make a grid over the study area and save its geographic coordinates
MARGIN = 8000 # meters beyond all stations, diagonally
min_lon, min_lat, max_lon, max_lat = self.gtfsdb.extent()
geod = pyproj.Geod(ellps="WGS84")
min_lon, min_lat, arc_dist = geod.fwd(min_lon, min_lat, 180 + 45, MARGIN)
max_lon, max_lat, arc_dist = geod.fwd(max_lon, max_lat, 45, MARGIN)
proj = pyproj.Proj(proj="sinu", ellps="WGS84")
min_x, min_y = proj(min_lon, min_lat)
proj = pyproj.Proj(
proj="sinu", ellps="WGS84", lon_0=min_lon, y_0=-min_y
) # why doesn't m parameter work for scaling by 100?
grid_dim = array(proj(max_lon, max_lat), dtype=int32) / 100
max_x, max_y = grid_dim
print "\nMaking grid with dimesions: ", max_x, max_y
self.emit(QtCore.SIGNAL("say(QString)"), QtCore.QString("Making %i by %i grid..." % (max_x, max_y)))
# later, use reshape/flat to switch between 1d and 2d array representation
grid_latlon = empty((max_x, max_y, 2), dtype=float32)
for y in range(0, max_y):
self.emit(QtCore.SIGNAL("progress(int, int)"), y, max_y)
for x in range(0, max_x):
# inverse project meters to lat/lon
grid_latlon[x, y] = proj(x * 100, y * 100, inverse=True)
station_vertices = [v for v in g.vertices if v.label[0:4] == "sta-"]
station_labels = [v.label for v in station_vertices]
n_stations = len(station_vertices)
print "Finding station coordinates..."
self.emit(QtCore.SIGNAL("say(QString)"), QtCore.QString("Projecting station coordinates..."))
station_coords = empty((n_stations, 2), dtype=float32)
for i, label in enumerate(station_labels):
stop_id, stop_name, lat, lon = self.gtfsdb.stop(label[4:])
station_coords[i] = proj(lon, lat)
if i % 20 == 0:
self.emit(QtCore.SIGNAL("progress(int, int)"), i, n_stations)
station_coords /= 100
# ELIMINATE STATIONS WITH SAME INTEGRAL COORDINATES
# self.emit( QtCore.SIGNAL( 'say(QString)' ), QtCore.QString( 'Eliminating equivalent stations...' ) )
# while len(station_coords) > 0 :
# coord =
# mask = station_coords != station_coords[i]
# station_coords = station_coords[mask]
# newer version follows
# self.emit( QtCore.SIGNAL( 'say(QString)' ), QtCore.QString( 'Eliminating equivalent stations...' ) )
# station_labels = np.array(station_labels)
# station_coords_new = []
# station_labels_new = []
# while len(station_coords) > 0 :
# coord = np.round(station_coords[0])
# minIdx = np.argmin(np.sum(np.abs(station_coords - coord), axis=1))
# station_labels_new.append(station_labels[minIdx])
# station_coords_new.append(station_coords[minIdx])
# mask = np.any(np.round(station_coords) != coord, axis=1)
# #print mask
# #print len(station_coords)
# #print coord
# #print station_coords[np.logical_not(mask)]
# station_coords = station_coords[mask][:]
# station_labels = station_labels[mask][:]
# self.emit( QtCore.SIGNAL( 'progress(int, int)' ), n_stations - len(station_coords_new), n_stations )
#
# station_labels = station_labels_new
# station_coords = station_coords_new
# station_vertices = [g.get_vertex(slabel) for slabel in station_labels_new]
# n_stations = len(station_labels)
# print len(station_labels), len(station_coords), len(station_vertices)
print "Making OD matrix..."
os.environ["TZ"] = "US/Pacific"
time.tzset()
t0s = "Tue Mar 09 08:00:00 2010"
t0t = time.strptime(t0s)
d0s = time.strftime("%a %b %d %Y", t0t)
t0 = int(time.mktime(t0t))
print "search date: ", d0s
print "search time: ", time.ctime(t0), t0
wo = WalkOptions()
wo.max_walk = 20000
wo.walking_overage = 0.1
wo.walking_speed = 1 # trimet uses 0.03 miles / 1 minute
wo.transfer_penalty = 60 * 10
wo.walking_reluctance = 2
wo.max_transfers = 40
wo.transfer_slack = 60 * 4
matrix = zeros(
(n_stations, n_stations), dtype=float
) # dtype could be uint16 except that there are inf's ---- why?
colortable = [QtGui.QColor(i, i, i).rgb() for i in range(256)]
colortable[254] = QtGui.QColor(050, 128, 050).rgb()
#.........这里部分代码省略.........