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


Python core.WalkOptions类代码示例

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


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

示例1: _points

 def _points(self, vertex_label, starttime, cutoff, speed):
     starttime = starttime or time.time()
     
     #=== find shortest path tree ===
     print "Finding shortest path tree"
     t0 = time.time()
     wo = WalkOptions()
     wo.walking_speed = speed
     spt = self.graph.shortest_path_tree( vertex_label, None, State(1,starttime), wo, maxtime=starttime+int(cutoff*1.25) )
     wo.destroy()
     t1 = time.time()
     print "took %s s"%(t1-t0)
     
     #=== cobble together ETA surface ===
     print "Creating ETA surface from OSM points..."
     points = []
     t0 = time.time()
     for vertex in spt.vertices:
         if "osm" in vertex.label:
             x, y = self.node_positions[vertex.label[3:]]
             points.append( (x, y, vertex.payload.time-starttime) )
     t1 = time.time()
     print "Took %s s"%(t1-t0)
     
     spt.destroy()
     
     return points
开发者ID:dru,项目名称:graphserver,代码行数:27,代码来源:contourserver.py

示例2: vertex

 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,代码行数:59,代码来源:graphcrawler.py

示例3: path_raw_retro

    def path_raw_retro(self, origin, dest, currtime):
        
        wo = WalkOptions()
        spt = self.graph.shortest_path_tree_retro( origin, dest, State(1,currtime), wo )
        wo.destroy()
        
        vertices, edges = spt.path_retro( origin )
        
        ret = postprocess_path_raw(vertices, edges)

        spt.destroy()
        
        return ret
开发者ID:ninowalker,项目名称:graphserver,代码行数:13,代码来源:routeserver.py

示例4: path_raw_retro

    def path_raw_retro(self, origin, dest, currtime):
        
        wo = WalkOptions()
        spt = self.graph.shortest_path_tree_retro( origin, dest, State(1,currtime), wo )
        wo.destroy()
        
        vertices, edges = spt.path_retro( origin )
        
        ret = "\n".join([str(x) for x in vertices]) + "\n\n" + "\n".join([str(x) for x in edges])

        spt.destroy()
        
        return ret
开发者ID:mtziotis,项目名称:graphserver,代码行数:13,代码来源:routeserver.py

示例5: make_native_ch

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,代码行数:14,代码来源:main.py

示例6: path

 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,代码行数:54,代码来源:routeserver.py

示例7: path_raw

 def path_raw(self, origin, dest, currtime=None):
     if currtime is None:
         currtime = int(time.time())
     
     wo = WalkOptions()
     spt = self.graph.shortest_path_tree( origin, dest, State(1,currtime), wo )
     wo.destroy()
     
     vertices, edges = spt.path( dest )
     
     ret = postprocess_path_raw(vertices, edges)
 
     spt.destroy()
     
     return ret
开发者ID:ninowalker,项目名称:graphserver,代码行数:15,代码来源:routeserver.py

示例8: path

    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,代码行数:58,代码来源:routeserver.py

示例9: path_retro

 def path_retro(self, origin, dest, currtime, transfer_penalty=0, walking_speed=1.0):
     
     wo = WalkOptions()
     wo.transfer_penalty = transfer_penalty
     wo.walking_speed = walking_speed
     spt = self.graph.shortest_path_tree_retro( origin, dest, State(1,currtime), wo )
     wo.destroy()
     
     vertices, edges = spt.path_retro( origin )
     
     ret = []
     for i in range(len(edges)):
         edgetype = edges[i].payload.__class__
         if edgetype in self.event_dispatch:
             ret.append( self.event_dispatch[ edges[i].payload.__class__ ]( vertices[i], edges[i], vertices[i+1] ) )
     
     spt.destroy()
     
     return json.dumps(ret)
开发者ID:mtziotis,项目名称:graphserver,代码行数:19,代码来源:routeserver.py

示例10: path_retro

 def path_retro(self, origin, dest, currtime=None, time_offset=None, transfer_penalty=0, walking_speed=1.0):
     if currtime is None:
         currtime = int(time.time())
         
     if time_offset is not None:
         currtime += time_offset
     
     wo = WalkOptions()
     wo.transfer_penalty = transfer_penalty
     wo.walking_speed = walking_speed
     spt = self.graph.shortest_path_tree_retro( origin, dest, State(1,currtime), wo )
     wo.destroy()
     
     vertices, edges = spt.path_retro( origin )
     
     ret = list(postprocess_path(vertices, edges, self.vertex_events, self.edge_events))
     
     spt.destroy()
     
     return json.dumps(ret, indent=2, cls=SelfEncoderHelper)
开发者ID:ninowalker,项目名称:graphserver,代码行数:20,代码来源:routeserver.py

示例11: _walk_edges_general

    def _walk_edges_general(self, forward_dir, label, time):
        vertex = self.gg.get_vertex( label )
        init_state = self._parse_init_state(self.gg.numagencies, time)

        dest_states = []
        for edge in vertex.outgoing:
            if forward_dir:
                if hasattr( edge.payload, 'collapse' ):
                    collapsed = edge.payload.collapse( init_state )
                else:
                    collapsed = edge.payload
                if collapsed:
                    wo = WalkOptions()
                    dest_states.append( (edge, collapsed, collapsed.walk( init_state,wo )) )
                    wo.destroy()
            else:
                if hasattr( edge.payload, 'collapse_back' ):
                    collapsed = edge.payload.collapse_back( init_state )
                else:
                    collapsed = edge.payload
                if collapsed:
                    wo = WalkOptions()
                    dest_states.append( (edge, collapsed, collapsed.walk_back( init_state,wo )) )
                    wo.destroy()
        
        def sort_states(x,y):
            if x[2] is None:
                return 1
            if y[2] is None:
                return -1
            else:
                return cmp(x[2].weight, y[2].weight)
        
        dest_states.sort(cmp=sort_states) #sort by weight of final state
        
        #====================

        ret = ["<?xml version='1.0'?>"]
        ret.append("<vertex>")
        ret.append(init_state.to_xml())
        ret.append("<outgoing_edges>")
        for edge, collapsed, sprime in dest_states:
            ret.append("<edge>")
            ret.append("<destination label='%s'>" % edge.to_v.label)
            if sprime:
                ret.append(sprime.to_xml())
            else:
                ret.append("<state/>")
            ret.append("</destination>")
            if collapsed:
                ret.append("<payload>%s</payload>" % collapsed.to_xml())
            else:
                ret.append("<payload/>")
            ret.append("</edge>")
        ret.append("</outgoing_edges>")
        ret.append("</vertex>")
        return "".join(ret)
开发者ID:jsoma,项目名称:graphserver,代码行数:57,代码来源:engine.py

示例12: __init__

    def __init__(self, graph, db_connection_string, time_step=240, walking_speed=1.2, max_walk=1080, walking_reluctance=2, trip_prefix='', logfile = None):

        self.trip_prefix = trip_prefix
        self.time_step = time_step

        self.walk_ops = WalkOptions()
        self.walk_ops.walking_speed = walking_speed
        self.walk_ops.max_walk = max_walk
        self.walk_ops.walking_reluctance = walking_reluctance

        self.graph = graph
        self.conn = psycopg2.connect(db_connection_string)
        self.cursor = self.conn.cursor()
        self.trip_id = 0
        self.trips_calculated = 0
        self.logfile = logfile

        self.run()
开发者ID:MaxBo,项目名称:graphserver,代码行数:18,代码来源:process_routes.py

示例13: get_cell_weights

 def get_cell_weights(self, cellIndex=0, dep_time=0):
     sys.stderr.write("get_cell_weights   cell index: " + str(cellIndex) + "\n")
     # if the departure time is not specified, set it
     if (dep_time == 0):
         dep_time = int(time.time())
     wo = WalkOptions()
     wo.transfer_penalty=60
     wo.walking_speed=1.0
     wo.walking_reluctance=1.0
     wo.max_walk=10000
     wo.walking_overage=0.1
     core.shortestPathForKDTree(self.graph, State(self.graph.num_agencies,dep_time), wo, cellIndex)
     yield "Finished!"
开发者ID:jeriksson,项目名称:graphserver,代码行数:13,代码来源:routeserver_xml.py

示例14: path

 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,代码行数:39,代码来源:routeserver.py

示例15: vertex

 def vertex(self, label, currtime=None):
     currtime = currtime or int(time.time())
     
     ret = []
     ret.append( "<h1>%s</h1>"%label )
     
     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()
         s0 = edgetype.walk_back( s1, wo )
         wo.destroy()
         
         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()
         s1 = edgetype.walk( s0, wo )
         wo.destroy()
         
         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)) )
             
     return "".join(ret)
开发者ID:dru,项目名称:graphserver,代码行数:42,代码来源:graphcrawler.py


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