当前位置: 首页>>代码示例>>Python>>正文


Python WalkOptions.transit_types方法代码示例

本文整理汇总了Python中graphserver.core.WalkOptions.transit_types方法的典型用法代码示例。如果您正苦于以下问题:Python WalkOptions.transit_types方法的具体用法?Python WalkOptions.transit_types怎么用?Python WalkOptions.transit_types使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在graphserver.core.WalkOptions的用法示例。


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

示例1: path_xml

# 需要导入模块: from graphserver.core import WalkOptions [as 别名]
# 或者: from graphserver.core.WalkOptions import transit_types [as 别名]

#.........这里部分代码省略.........
            
            #print "Origin time: " + str(time_to_orig)
            #print "Destination time: " + str(time_to_dest)
            
            # adjust departure time by time needed to reach origin node
            dep_time = (dep_time + time_to_orig)
            
            # adjust arrival time by time needed to reach destination node
            if (arr_time != 0):
                arr_time = (arr_time - time_to_dest)
            
            #print "Adjusted departure time: " + str(dep_time)
            
            # set walk options
            wo.transfer_penalty=transfer_penalty
            wo.walking_speed=walking_speed
            wo.walking_reluctance=walking_reluctance
            wo.max_walk=max_walk
            wo.walking_overage=walking_overage
            
            # check for wheelchair street_mode
            if (street_mode == "wheelchair"):
                wo.with_wheelchair = int(True)
                wo.transfer_penalty = 180
            else:
                wo.with_wheelchair = int(False)
            
            # check for bike street_mode
            if (street_mode == "bike"):
                wo.transfer_penalty = 120
            
            # check for transit_mode
            if (transit_mode == "Both"):
                wo.transit_types = int(14)
            elif (transit_mode == "Bus"):
                wo.transit_types = int(8)
            elif (transit_mode == "Rail"):
                wo.transit_types = int(6)
            elif (transit_mode == "None"):
                wo.transit_types = int(0)
            
            # check for less_walking flag
            if (less_walking == "True"):
                wo.walking_reluctance *= 10.0
            
            # create RouteInfo object
            route_info = RouteInfo()
            route_info.origlat = origlat
            route_info.origlon = origlon
            route_info.dep_time_diff = time_to_orig
            route_info.destlat = destlat
            route_info.destlon = destlon
            route_info.arr_time_diff = time_to_dest
            route_info.street_mode = street_mode
            
            yield "--multipart-path_xml-boundary1234\n";
            
			# loop to create multiple responses
            for q in range(max_results):
                if (spt is not None):
                    spt.destroy_no_hash()
                route_info.first_edge = True
                route_info.last_edge = False
                
                # initialize return string
                ret_string = 'Content-Type: text/xml\n\n<?xml version="1.0"?><routes>'
开发者ID:jeriksson,项目名称:graphserver,代码行数:70,代码来源:routeserver_xml.py

示例2: getUrbanExplorerBlob

# 需要导入模块: from graphserver.core import WalkOptions [as 别名]
# 或者: from graphserver.core.WalkOptions import transit_types [as 别名]
 def getUrbanExplorerBlob(self, origlon, origlat, destlon, destlat, arrive_time, street_mode="walk", transit_mode="Both", less_walking="False", transfer_penalty=60, walking_speed=1.0, walking_reluctance=1.0, max_walk=10000, walking_overage=0.1,start_time=0,switch=1):
     
     # get origin and destination nodes from osm map
     sys.stderr.write("[get_osm_vertex_from_coords," + str(time.time()) + "]\n")
     orig_osm, orig_osm_dist = self.pgosmdb.get_osm_vertex_from_coords(origlon, origlat)
     dest_osm, dest_osm_dist = self.pgosmdb.get_osm_vertex_from_coords(destlon, destlat)
         
     # get origin and destination nodes from gtfs database
     sys.stderr.write("[get_station_vertex_from_coords," + str(time.time()) + "]\n")
     orig_sta, orig_sta_dist = self.pggtfsdb.get_station_vertex_from_coords(origlon, origlat)
     dest_sta, dest_sta_dist = self.pggtfsdb.get_station_vertex_from_coords(destlon, destlat)
             
     # get coordinates for origin node
     if (orig_osm_dist < orig_sta_dist):
         origin = orig_osm
         sys.stderr.write("[get_coords_for_osm_vertex," + str(time.time()) + "]\n")
         orig_node_lat, orig_node_lon = self.pgosmdb.get_coords_for_osm_vertex(origin)
     else:
         origin = orig_sta
         sys.stderr.write("[get_coords_for_station_vertex," + str(time.time()) + "]\n")
         orig_node_lat, orig_node_lon = self.pggtfsdb.get_coords_for_station_vertex(origin)
             
     # get coordinates for destination node
     if (dest_osm_dist < dest_sta_dist):
         dest = dest_osm
         sys.stderr.write("[get_coords_for_osm_vertex," + str(time.time()) + "]\n")
         dest_node_lat, dest_node_lon = self.pgosmdb.get_coords_for_osm_vertex(dest)
     else:
         dest = dest_sta
         sys.stderr.write("[get_coords_for_station_vertex," + str(time.time()) + "]\n")
         dest_node_lat, dest_node_lon = self.pggtfsdb.get_coords_for_station_vertex(dest)
 
     wo = WalkOptions()
     wo.transfer_penalty=transfer_penalty
     wo.walking_speed=walking_speed
     wo.walking_reluctance=walking_reluctance
     wo.max_walk=max_walk
     wo.walking_overage=walking_overage
     
     # check for wheelchair street_mode
     if (street_mode == "wheelchair"):
         wo.with_wheelchair = int(True)
         wo.transfer_penalty = 180
     else:
         wo.with_wheelchair = int(False)
     
     # check for bike street_mode
     if (street_mode == "bike"):
         wo.transfer_penalty = 120
     
     # check for transit_mode
     if (transit_mode == "Both"):
         wo.transit_types = int(14)
     elif (transit_mode == "Bus"):
         wo.transit_types = int(8)
     elif (transit_mode == "Rail"):
         wo.transit_types = int(6)
     elif (transit_mode == "None"):
         wo.transit_types = int(0)
         
     # check for less_walking flag
     if (less_walking == "True"):
         wo.walking_reluctance *= 10.0
     
     if (start_time == 0):
         start_time = int(time.time())
 
     if (switch == 1):
         graphserver.core.makeImage(self.graph.soul, origin, dest, State(self.graph.num_agencies,start_time), State(self.graph.num_agencies,arrive_time), wo)
         return open("explorerimages/blah.png", "rb").read()
     else:
         graphserver.core.makeUrbanExplorerBlob(self.graph.soul, origin, dest, State(self.graph.num_agencies,start_time), State(self.graph.num_agencies,arrive_time), wo)
         return open("explorerimages/blah2.png", "rb").read()
开发者ID:jeriksson,项目名称:graphserver,代码行数:75,代码来源:routeserver_xml.py


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