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


Python WalkOptions.hill_reluctance方法代码示例

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


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

示例1: vertex

# 需要导入模块: from graphserver.core import WalkOptions [as 别名]
# 或者: from graphserver.core.WalkOptions import hill_reluctance [as 别名]
 def vertex(self, label, currtime=None, hill_reluctance=1.5, walking_speed=0.85):
     currtime = currtime or int(time.time())
     
     ret = []
     ret.append( "<h1>%s</h1>"%label )
     
     wo = WalkOptions()
     ret.append( "<h3>walk options</h3>" )
     ret.append( "<li>transfer_penalty: %s</li>"%wo.transfer_penalty )
     ret.append( "<li>turn_penalty: %s</li>"%wo.turn_penalty )
     ret.append( "<li>walking_speed: %s</li>"%wo.walking_speed )
     ret.append( "<li>walking_reluctance: %s</li>"%wo.walking_reluctance )
     ret.append( "<li>uphill_slowness: %s</li>"%wo.uphill_slowness )
     ret.append( "<li>downhill_fastness: %s</li>"%wo.downhill_fastness )
     ret.append( "<li>hill_reluctance: %s</li>"%wo.hill_reluctance )
     ret.append( "<li>max_walk: %s</li>"%wo.max_walk )
     ret.append( "<li>walking_overage: %s</li>"%wo.walking_overage )
     
     
     ret.append( "<h3>incoming from:</h3>" )
     for i, (vertex1, vertex2, edgetype) in enumerate( self.graphdb.all_incoming( label ) ):
         s1 = State(1,int(currtime))
         wo = WalkOptions()
         wo.hill_reluctance=hill_reluctance
         wo.walking_speed=walking_speed
         s0 = edgetype.walk_back( s1, wo )
         
         if s0:
             toterm = "<a href=\"/vertex?label=&quot;%s&quot;&currtime=%d\">%[email protected]%d</a>"%(vertex1, s0.time, vertex1, s1.time)
         else:
             toterm = "<a href=\"/vertex?label=&quot;%s&quot;\">%s</a>"%(vertex1, vertex1)
         
         ret.append( "%s<br><pre>&nbsp;&nbsp;&nbsp;via %s (<a href=\"/incoming?label=&quot;%s&quot;&edgenum=%d\">details</a>)</pre>"%(toterm, cgi.escape(repr(edgetype)), vertex2, i) )
         
         if s0:
             ret.append( "<pre>&nbsp;&nbsp;&nbsp;%s</pre>"%cgi.escape(str(s0)) )
         
         
     ret.append( "<h3>outgoing to:</h3>" )
     for i, (vertex1, vertex2, edgetype) in enumerate( self.graphdb.all_outgoing( label ) ):
         s0 = State(1,int(currtime))
         wo = WalkOptions()
         wo.hill_reluctance=hill_reluctance
         wo.walking_speed=walking_speed
         s1 = edgetype.walk( s0, wo )
         
         if s1:
             toterm = "<a href=\"/vertex?label=&quot;%s&quot;&currtime=%d\">%[email protected]%d</a>"%(vertex2, s1.time, vertex2, s1.time)
         else:
             toterm = "<a href=\"/vertex?label=&quot;%s&quot;\">%s</a>"%(vertex2, vertex2)
         
         ret.append( "%s<br><pre>&nbsp;&nbsp;&nbsp;via %s (<a href=\"/outgoing?label=&quot;%s&quot;&edgenum=%d\">details</a>)</pre>"%(toterm, cgi.escape(repr(edgetype)), vertex1, i) )
         
         if s1:
             ret.append( "<pre>&nbsp;&nbsp;&nbsp;%s</pre>"%cgi.escape(str(s1)) )
     
     wo.destroy()
     
     return "".join(ret)
开发者ID:Jamie5,项目名称:graphserver,代码行数:61,代码来源:graphcrawler.py

示例2: path

# 需要导入模块: from graphserver.core import WalkOptions [as 别名]
# 或者: from graphserver.core.WalkOptions import hill_reluctance [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

示例3: path

# 需要导入模块: from graphserver.core import WalkOptions [as 别名]
# 或者: from graphserver.core.WalkOptions import hill_reluctance [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

示例4: make_native_ch

# 需要导入模块: from graphserver.core import WalkOptions [as 别名]
# 或者: from graphserver.core.WalkOptions import hill_reluctance [as 别名]
def make_native_ch(basename):
    gdb = GraphDatabase( basename+".gdb" )
    gg = gdb.incarnate()
    
    
    wo = WalkOptions()
    wo.hill_reluctance=20
    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,代码行数:16,代码来源:main.py

示例5: path

# 需要导入模块: from graphserver.core import WalkOptions [as 别名]
# 或者: from graphserver.core.WalkOptions import hill_reluctance [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

示例6: get_walk

# 需要导入模块: from graphserver.core import WalkOptions [as 别名]
# 或者: from graphserver.core.WalkOptions import hill_reluctance [as 别名]
def get_walk( lat1, lon1, lat2, lon2 ):
    vertex1 = get_nearest_vertex( lat1, lon1 )
    vertex2 = get_nearest_vertex( lat2, lon2 )

    wo = WalkOptions()
    wo.transfer_penalty = 0
    wo.walking_speed = 1.0
    wo.hill_reluctance = 1.5

    try:
        spt = graph.shortest_path_tree( vertex1, vertex2, State(1, starttime), wo )
        vertices, edges = spt.path( vertex2 )
    except Exception:
        print "couldn't find a path between (%.4f,%4f) and (%.4f,%.4f)" % ( lat1, lon1, lat2, lon2)
        return None

    first_walk_time = None
    last_walk_time = None
    walk_streets = []
    walk_points = []
    walk_distance = 0

    for edge1,vertex1,edge2,vertex2 in zip( [None]+edges, vertices, edges+[None], vertices[1:]+[None,None] ):

        edge1payload = edge1.payload if edge1 else None
        edge2payload = edge2.payload if edge2 else None

        if edge2 is not None and isinstance(edge2.payload, Street):

            # Add the street geometry for this edge to our walk_points
            geometry_chunk = osmdb.edge( edge2.payload.name )[5]

            if edge2.payload.reverse_of_source:
                walk_points.extend( reversed( geometry_chunk ) )
            else:
                walk_points.extend( geometry_chunk )

            # Add this edge's distance in meters to the walk_distance
            walk_distance += edge2.payload.length

        if edge1 and edge2 and isinstance(edge1.payload, Street) and edge1.payload.way != edge2.payload.way:

            # We hit a turn

            walk_streets.append(get_street_name_for_edge(edge2))

        if (edge1 is None or not isinstance(edge1.payload, Street)) and (edge2 and isinstance(edge2.payload, Street)):

            # We started walking

            walk_streets.append(get_street_name_for_edge(edge2))

            if first_walk_time is None:
                first_walk_time = vertex1.state.time

        if (edge1 and isinstance(edge1.payload, Street)) and (edge2 is None or not isinstance(edge2.payload, Street)):

            # We stopped walking

            last_walk_time = vertex1.state.time

    if first_walk_time is None or last_walk_time is None:
        walk_time = 0
    else:
        walk_time = last_walk_time - first_walk_time

    ret = Walk()
    ret.time = walk_time
    ret.streets = walk_streets
    ret.points = walk_points
    ret.distance = walk_distance / 1609.344 # convert to miles

    return ret
开发者ID:apparentlymart,项目名称:proximo-connector,代码行数:75,代码来源:findadjacentstops.py

示例7: return

# 需要导入模块: from graphserver.core import WalkOptions [as 别名]
# 或者: from graphserver.core.WalkOptions import hill_reluctance [as 别名]
        start_time -= origin_walk_penalty
    finally:
        if tree:
            tree.destroy()

        return (start_time, stop_time)

    #narrative = list(postprocess_path(vertices, edges))
    #return json.dumps({ 'narrative': narrative }, indent=3, cls=SelfEncoderHelper)

walk_options = WalkOptions()

walk_options.transfer_penalty = 0
walk_options.walking_speed = 1.0
walk_options.hill_reluctance = 1.5
#walk_options.turn_penalty = 
#walk_options.walking_reluctance = 
#walk_options.max_walk = 

# The full Metro King County boundaries
#lon_start = -122.506729
#lon_stop = -121.785828
#lat_start = 47.9323654
#lat_stop = 47.1891136

# Seattle & the East side
lat_start = 47.7
lat_stop = 47.5
lon_start = -122.433
lon_stop = -122.04
开发者ID:beaugunderson,项目名称:transit-heatmap,代码行数:32,代码来源:route.py


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