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


Python WalkOptions.turn_penalty方法代码示例

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


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

示例1: path

# 需要导入模块: from graphserver.core import WalkOptions [as 别名]
# 或者: from graphserver.core.WalkOptions import turn_penalty [as 别名]
    def path(self, lat1, lng1, lat2, lng2, transfer_penalty=0, walking_speed=1.0, hill_reluctance=20, narrative=True, jsoncallback=None):
        
        t0 = time.time()
        origin = "osm-%s"%self.osmdb.nearest_node( lat1, lng1 )[0]
        dest = "osm-%s"%self.osmdb.nearest_node( lat2, lng2 )[0]
        endpoint_find_time = time.time()-t0
        
        print origin, dest
        
        t0  = time.time()
        wo = WalkOptions()
        #wo.transfer_penalty=transfer_penalty
        #wo.walking_speed=walking_speed
        wo.walking_speed=4
        wo.walking_overage = 0
        wo.hill_reluctance = 20
        wo.turn_penalty = 15 
        
        edgepayloads = self.ch.shortest_path( origin, dest, State(1,0), wo )
        
        wo.destroy()
        
        route_find_time = time.time()-t0
        
        t0 = time.time()
        names = []
        geoms = []
        
        profile = Profile()
        total_dist = 0
        total_elev = 0
        
        if narrative:
            names, total_dist = get_full_route_narrative( self.osmdb, edgepayloads )
        
        for edgepayload in edgepayloads:
            geom, profile_seg = self.shortcut_cache.get( edgepayload.external_id )
            
            #geom = get_ep_geom( self.osmdb, edgepayload )
            #profile_seg = get_ep_profile( self.profiledb, edgepayload )

            geoms.extend( geom )
            profile.add( profile_seg )
            
        route_desc_time = time.time()-t0

        ret = json.dumps( (names, 
                           encode_pairs( [(lat, lon) for lon, lat in geoms] ), 
                           profile.concat(300),
                           { 'route_find_time':route_find_time,
                             'route_desc_time':route_desc_time,
                             'endpoint_find_time':endpoint_find_time,},
                           { 'total_dist':total_dist,
                             'total_elev':total_elev}) )
        if jsoncallback:
            return "%s(%s)"%(jsoncallback,ret)
        else:
            return ret
开发者ID:bmander,项目名称:gstrip,代码行数:60,代码来源:routeserver.py

示例2: path

# 需要导入模块: from graphserver.core import WalkOptions [as 别名]
# 或者: from graphserver.core.WalkOptions import turn_penalty [as 别名]
 def path(self, 
          origin, 
          dest,
          currtime=None, 
          time_offset=None, 
          transfer_penalty=0, 
          walking_speed=1.0,
          hill_reluctance=1.5,
          turn_penalty=None,
          walking_reluctance=None,
          max_walk=None,
          jsoncallback=None):
     
     performance = {}
     
     if currtime is None:
         currtime = int(time.time())
         
     if time_offset is not None:
         currtime += time_offset
     
     # time path query
     t0 = time.time()
     wo = WalkOptions()
     wo.transfer_penalty=transfer_penalty
     wo.walking_speed=walking_speed
     wo.hill_reluctance=hill_reluctance
     if turn_penalty is not None:
         wo.turn_penalty = turn_penalty
     if walking_reluctance is not None:
         wo.walking_reluctance = walking_reluctance
     if max_walk is not None:
         wo.max_walk = max_walk
     spt = self.graph.shortest_path_tree( origin, dest, State(1,currtime), wo )
     
     
     vertices, edges = spt.path( dest )
     performance['path_query_time'] = time.time()-t0
     
     t0 = time.time()
     narrative = list(postprocess_path(vertices, edges, self.vertex_events, self.edge_events))
     performance['narrative_postprocess_time'] = time.time()-t0
     
     t0 = time.time()
     wo.destroy()
     spt.destroy()
     performance['cleanup_time'] = time.time()-t0
     
     ret = {'narrative':narrative, 'performance':performance}
     
     if jsoncallback is None:
         return json.dumps(ret, indent=2, cls=SelfEncoderHelper)
     else:
         return "%s(%s)"%(jsoncallback,json.dumps(ret, indent=2, cls=SelfEncoderHelper))
开发者ID:ninowalker,项目名称:graphserver,代码行数:56,代码来源:routeserver.py

示例3: make_native_ch

# 需要导入模块: from graphserver.core import WalkOptions [as 别名]
# 或者: from graphserver.core.WalkOptions import turn_penalty [as 别名]
def make_native_ch(basename):
    gdb = GraphDatabase( basename+".gdb" )
    gg = gdb.incarnate()
    
    
    wo = WalkOptions()
    wo.hill_reluctance=20
    wo.walking_speed=4
    wo.walking_overage = 0
    wo.turn_penalty = 15

    ch = gg.get_contraction_hierarchies( wo )
            
    chdowndb = GraphDatabase( basename+".down.gdb", overwrite=True )
    chdowndb.populate( ch.downgraph, reporter=sys.stdout )
    
    chupdb = GraphDatabase( basename+".up.gdb", overwrite=True )
    chupdb.populate( ch.upgraph, reporter=sys.stdout )
开发者ID:bmander,项目名称:gstrip,代码行数:20,代码来源:ch.py

示例4: path

# 需要导入模块: from graphserver.core import WalkOptions [as 别名]
# 或者: from graphserver.core.WalkOptions import turn_penalty [as 别名]
 def path(self, 
          origin, 
          dest,
          currtime=None, 
          time_offset=None, 
          transfer_penalty=0, 
          walking_speed=1.0,
          hill_reluctance=1.5,
          turn_penalty=None,
          walking_reluctance=None,
          max_walk=None,
          jsoncallback=None):
     
     performance = {}
     
     if currtime is None:
         currtime = int(time.time())
         
     if time_offset is not None:
         currtime += time_offset
     
     # time path query
     t0 = time.time()
     wo = WalkOptions()
     wo.transfer_penalty=transfer_penalty
     wo.walking_speed=walking_speed
     wo.hill_reluctance=hill_reluctance
     if turn_penalty is not None:
         wo.turn_penalty = turn_penalty
     if walking_reluctance is not None:
         wo.walking_reluctance = walking_reluctance
     if max_walk is not None:
         wo.max_walk = max_walk
     spt = self.graph.shortest_path_tree( origin, dest, State(1,currtime), wo, maxtime=4000000000, hoplimit=2000000, weightlimit=4000000000 )
    
     try:
         vertices, edges = spt.path( dest )
     except Exception, e:
         return json.dumps( {'error':str(e)} )
开发者ID:dzwarg,项目名称:graphserver,代码行数:41,代码来源:routeserver.py


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