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


Python GraphDatabase.incarnate方法代码示例

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


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

示例1: reincarnate_ch

# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import incarnate [as 别名]
def reincarnate_ch(basename):
    chdowndb = GraphDatabase( basename+".down.gdb" )
    chupdb = GraphDatabase( basename+".up.gdb" )
    
    upgg = chupdb.incarnate()
    downgg = chdowndb.incarnate()
    
    return ContractionHierarchy(upgg, downgg)
开发者ID:bmander,项目名称:gstrip,代码行数:10,代码来源:shortcut_cache.py

示例2: __init__

# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import incarnate [as 别名]
 def __init__(self, graphdb_filename, pgosmdb_handle, pggtfsdb_handle, event_dispatch):
     graphdb = GraphDatabase( graphdb_filename )
     self.graph = graphdb.incarnate()
     self.graph.num_agencies = 3
     self.graph.numagencies = self.graph.num_agencies
     self.event_dispatch = event_dispatch
     self.pgosmdb = pgosmdb_handle
     self.pggtfsdb = pggtfsdb_handle
     self.two_way_routing = True
开发者ID:jeriksson,项目名称:graphserver,代码行数:11,代码来源:routeserver_xml.py

示例3: handle

# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import incarnate [as 别名]
    def handle(self, *args, **options):
        self.stdout.write('Loading boston.osmdb\n')
        self.nodedb = osmdb.OSMDB(settings.DATA_DIR+'/boston.osmdb')

        self.stdout.write('Importing Boston street network...\n')
        gdb = GraphDatabase(settings.DATA_DIR+'/boston.gdb')
        self.graph = gdb.incarnate()

        self.stdout.write('Importing trip network...\n')
        tripdb = osmdb.OSMDB(settings.DATA_DIR+'/trip_data.db')
        
        
        batchgeom = []
        count = 0

        # For each station
        for tnode in tripdb.nodes():
            lat1 = float(tnode[2])
            lng1 = float(tnode[3])
            
            # get all trips departing this station
            cursor = tripdb.get_cursor()
            tedges = cursor.execute("select * from edges where start_nd = ?", [tnode[0]])
            
            # For each trip
            for tedge in tedges:
                if tedge[3] == '':
                    if int(options['verbosity']) > 1:
                        self.stdout.write('Start and end nodes are the same.\n')
                    continue

                dnode = tripdb.node(tedge[3])

                lat2 = float(dnode[2])
                lng2 = float(dnode[3])

                dnode = None

                if lat2 == lat1 and lng2 == lng1:
                    continue

                geom = self._spt(lat1, lng1, lat2, lng2)
                count += 1

                batchgeom.append((count,geom,))
                
                if len(batchgeom) >= options['number']:
                    self.dropfile(batchgeom, count, **options)
                    batchgeom = []

                geom = None


            # Don't keep a history of the execute tranactions
            tedges = None
            cursor = None
开发者ID:dzwarg,项目名称:hubway-challenge,代码行数:58,代码来源:route_all.py

示例4: __init__

# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import incarnate [as 别名]
 def __init__(self, graphdb_filename, vertex_events, edge_events, vertex_reverse_geocoders):
     if os.path.exists("%s.gbin" % graphdb_filename):
         self.graph = Graph()
         self.graph.deserialize(graphdb_filename, os.path.exists("%s.gmm" % graphdb_filename))
     else:
         graphdb = GraphDatabase( graphdb_filename )
         self.graph = graphdb.incarnate()
     self.vertex_events = vertex_events
     self.edge_events = edge_events
     self.vertex_reverse_geocoders = vertex_reverse_geocoders
开发者ID:dzwarg,项目名称:graphserver,代码行数:12,代码来源:routeserver.py

示例5: make_native_ch

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

示例6: main

# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import incarnate [as 别名]
def main(graph_db, gtfs_db):     
    graphdb = GraphDatabase( graph_db )
    gtfsdb = GTFSDatabase( gtfs_db )
    print "loading existing graph"
    full_graph = graphdb.incarnate()
    print "copying relevant vertices and edges from full graph"
    min_graph = Graph()
    copy_relevant_elements( min_graph, full_graph )    
    print "adding minimum-time transit trip edges"
    add_min_transit( min_graph, gtfsdb )
    print "writing out new graph to database"
    min_graphdb = GraphDatabase( 'min_graph.gdb', overwrite=True )
    min_graphdb.populate(min_graph)
    print "DONE."
    sys.exit(0)    
开发者ID:abyrd,项目名称:metric-embedding,代码行数:17,代码来源:make_mingraph.py

示例7: __init__

# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import incarnate [as 别名]
 def __init__(self, settings_filename):
     settings = yaml.load( open( settings_filename ) )
     
     self.home_point = settings['center']
     
     # create cache of osm-node positions
     self.osmdb = OSMDB( settings['osmdb_filename'] )
     self.gtfsdb = GTFSDatabase( settings['gtfsdb_filename'] )
     self.port = settings['port']
     self.node_positions = {}
     self.index = Rtree()
     for node_id, tags, lat, lon in self.osmdb.nodes():
         self.node_positions[node_id] = (lon,lat)
         self.index.add( int(node_id), (lon,lat,lon,lat) )
     
     # incarnate graph from graphdb
     graphdb = GraphDatabase( settings['graphdb_filename'] )
     self.graph = graphdb.incarnate()
开发者ID:dru,项目名称:graphserver,代码行数:20,代码来源:contourserver.py

示例8: main

# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import incarnate [as 别名]
def main():
    usage = """usage: python gs_serialize.py [options] <basename> <graphdb_filename> """
    parser = OptionParser(usage=usage)
    parser.add_option("-m", "--memmap",
                      action="store_true", dest="memmap", default=False,
                      help="Create a memmap serialized file.")
    
    (options, args) = parser.parse_args()
    
    if len(args) != 2:
        parser.print_help()
        exit(-1)
    
    basename, graphdb_filename = args
    
    db = GraphDatabase(graphdb_filename)
    g = db.incarnate()
    g.serialize(basename, options.memmap)
    print "done"
开发者ID:dzwarg,项目名称:graphserver,代码行数:21,代码来源:gs_serialize.py

示例9: test_basic

# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import incarnate [as 别名]
 def test_basic(self):
     g = Graph()
     g.add_vertex("A")
     g.add_vertex("B")
     g.add_edge("A", "B", Link())
     g.add_edge("A", "B", Street("foo", 20.0))
     gdb_file = os.path.dirname(__file__) + "unit_test.db"
     if os.path.exists(gdb_file):
         os.remove(gdb_file)        
     gdb = GraphDatabase(gdb_file)
     gdb.populate(g)
     
     list(gdb.execute("select * from resources"))
     assert "A" in list(gdb.all_vertex_labels())
     assert "B" in list(gdb.all_vertex_labels())
     assert glen(gdb.all_edges()) == 2
     assert glen(gdb.all_outgoing("A")) == 2
     assert glen(gdb.all_outgoing("B")) == 0
     assert glen(gdb.all_incoming("A")) == 0
     assert glen(gdb.all_incoming("B")) == 2
     assert glen(gdb.resources()) == 0
     assert gdb.num_vertices() == 2
     assert gdb.num_edges() == 2
     
     g.destroy()
     g = gdb.incarnate()
     
     list(gdb.execute("select * from resources"))
     assert "A" in list(gdb.all_vertex_labels())
     assert "B" in list(gdb.all_vertex_labels())
     assert glen(gdb.all_edges()) == 2
     assert glen(gdb.all_outgoing("A")) == 2
     assert glen(gdb.all_outgoing("B")) == 0
     assert glen(gdb.all_incoming("A")) == 0
     assert glen(gdb.all_incoming("B")) == 2
     assert glen(gdb.resources()) == 0
     assert gdb.num_vertices() == 2
     assert gdb.num_edges() == 2
     
     os.remove( gdb_file )
开发者ID:Jamie5,项目名称:graphserver,代码行数:42,代码来源:test_graph_database.py

示例10: test_ch

# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import incarnate [as 别名]
    def test_ch(self):
        g = Graph()

	g.add_vertex( "A" )
	g.add_vertex( "B" )
        g.add_vertex( "C" )
	g.add_edge( "A", "B", Street( "foo", 10 ) )
	g.add_edge( "B", "C", Street( "bar", 10 ) )
	g.add_edge( "C", "A", Street( "baz", 10 ) )

        wo = WalkOptions()
	ch = g.get_contraction_hierarchies(wo)

        gdb_file = os.path.dirname(__file__) + "unit_test.db"
        gdb = GraphDatabase( gdb_file )
	gdb.populate( ch.upgraph )

	laz = gdb.incarnate()

        combo = laz.edges[1]
	self.assertEqual( combo.payload.get(0).name, "baz" )
	self.assertEqual( combo.payload.get(1).name, "foo" )

	os.remove( gdb_file )
开发者ID:Jamie5,项目名称:graphserver,代码行数:26,代码来源:test_graph_database.py

示例11: main

# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import incarnate [as 别名]
def main(count):
    print 'Loading boston.osmdb'
    nodedb = osmdb.OSMDB(DATA_DIR+'boston.osmdb')

    print 'Importing Boston street network...'
    gdb = GraphDatabase(DATA_DIR+'boston.gdb')
    graph = gdb.incarnate()

    print 'Importing trip network...'
    tripdb = osmdb.OSMDB(DATA_DIR+'trip_data.db')
    
    stime = time()
    wo = WalkOptions()
    
    cursor = tripdb.get_cursor()
    
    tripcount = 0

    # For each station
    for tnode in tripdb.nodes():
        lat1 = float(tnode[2])
        lng1 = float(tnode[3])
        
        # find origin node on the street network
        orig = nodedb.nearest_node(lat1, lng1)
        
        # get all trips departing this station
        tedges = cursor.execute("select * from edges where start_nd = ?", [tnode[0]])
        
        # For each trip
        for tedge in tedges:
            dnode = tripdb.node(tedge[3])
            
            lat2 = float(dnode[2])
            lng2 = float(dnode[3])
            
            if lat2 == lat1 and lng2 == lng1:
                # Do not route something that ends where it begins
                print 'Begin and end node are the same.'
            else:
                # find the destination node on the street network
                dest = nodedb.nearest_node(lat2, lng2)
            
                # route!
                spt = graph.shortest_path_tree('osm-'+orig[0], 'osm-'+dest[0], State(1,stime), wo)
            
                # get the path vertices and edges
                pvert, pedges = spt.path('osm-'+dest[0])
            
                # convert the results to geometries
                allgeom = []
                for e in pedges:
                    dbedge = nodedb.edge(e.payload.name)
                    if e.payload.reverse_of_source:
                        allgeom.extend( reversed( dbedge[5] ) )
                    else:
                        allgeom.extend( dbedge[5] )
            
                print allgeom
            
            tripcount += 1
            
            if tripcount >= count:
                break
        
        if tripcount >= count:
            break
开发者ID:dzwarg,项目名称:hubway-challenge,代码行数:69,代码来源:router.py

示例12: OptionParser

# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import incarnate [as 别名]
    usage = """usage: python zzzz.py <graph_database> <assist_graph_database> <osm_database> <gtfs_database>"""
    parser = OptionParser(usage=usage)
    (options, args) = parser.parse_args()
    if len(args) != 4:
        parser.print_help()
        exit(-1)
        
    graph_db = args[0]
    assist_graph_db = args[1]
    osm_db  = args[2]    
    gtfs_db = args[3]    
    graphdb = GraphDatabase( graph_db )
    assistgraphdb = GraphDatabase( assist_graph_db )
    osmdb = OSMDB( osm_db )
    gtfsdb = GTFSDatabase( gtfs_db )
    g = graphdb.incarnate()
    ag = assistgraphdb.incarnate() 

    nodes = {}
    for id, tags, lat, lon, endnode_refs in osmdb.nodes():
        nodes['osm-' + id] = (lat, lon)
    for id, name, lat, lon in gtfsdb.stops():
        nodes['sta-' + id] = (lat, lon)

    os.environ['TZ'] = 'US/Pacific'
    time.tzset()
    t0s = "Tue Nov 16 07:50:30 2010"
    t0t = time.strptime(t0s)
    d0s = time.strftime('%a %b %d %Y', t0t)
    t0  = time.mktime(t0t)
    print 'search date: ', d0s
开发者ID:abyrd,项目名称:metric-embedding,代码行数:33,代码来源:test_mingraph.py

示例13: GTFSDatabase

# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import incarnate [as 别名]
from PIL import Image
from multiprocessing import Pool

os.environ['TZ'] = 'US/Pacific'
time.tzset()
t0s = "Mon May 17 08:50:00 2010"
t0t = time.strptime(t0s)
d0s = time.strftime('%a %b %d %Y', t0t)
t0  = time.mktime(t0t)
print 'search date: ', d0s
print 'search time: ', time.ctime(t0), t0

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() 
开发者ID:abyrd,项目名称:metric-embedding,代码行数:33,代码来源:make_od_multi.py

示例14: __init__

# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import incarnate [as 别名]
 def __init__(self, graphdb_filename, event_dispatch):
     graphdb = GraphDatabase( graphdb_filename )
     self.graph = graphdb.incarnate()
     self.event_dispatch = event_dispatch
开发者ID:mtziotis,项目名称:graphserver,代码行数:6,代码来源:routeserver.py

示例15: GraphDatabase

# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import incarnate [as 别名]
except ImportError:
    import simplejson as json

graphdb_filename = "sanfrancisco.gdb"
osmdb_filename = "sanfrancisco.osmdb"
munistops_filename = "munistops.json"
munistopsdb_filename = "munistops.db"

starttime = 0
lat_adj_tolerance = 0.002
lon_adj_tolerance = 0.002
walk_adj_tolerance = 180 # 3 minutes

munistops = json.load(file(munistops_filename))
graphdb = GraphDatabase( graphdb_filename )
graph = graphdb.incarnate()
osmdb = OSMDB( osmdb_filename )
try:
    os.remove(munistopsdb_filename)
except OSError:
    pass
munistopsdb = sqlite3.connect(munistopsdb_filename)

def main():

    set_up_munistopsdb_schema()

    pairs = 0

    for start_stop_id, end_stop_id in adjacent_muni_stops_by_coords():
        start_stop = munistops[start_stop_id]
开发者ID:apparentlymart,项目名称:proximo-connector,代码行数:33,代码来源:findadjacentstops.py


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