本文整理汇总了Python中graphserver.graphdb.GraphDatabase.populate方法的典型用法代码示例。如果您正苦于以下问题:Python GraphDatabase.populate方法的具体用法?Python GraphDatabase.populate怎么用?Python GraphDatabase.populate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graphserver.graphdb.GraphDatabase
的用法示例。
在下文中一共展示了GraphDatabase.populate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_transit_graph
# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import populate [as 别名]
def process_transit_graph(graphdb_filename, gtfsdb_filenames, osmdb_filename=None, profiledb_filename=None, agency_id=None, link_stations=False, slogs={}):
g = Graph()
if profiledb_filename:
print( "Opening ProfileDB '%s'"%profiledb_filename )
profiledb = ProfileDB( profiledb_filename )
else:
print( "No ProfileDB supplied" )
profiledb = None
if osmdb_filename:
# Load osmdb ===============================
print( "Opening OSM-DB '%s'"%osmdb_filename )
osmdb = OSMDB( osmdb_filename )
compiler.load_streets_to_graph( g, osmdb, profiledb, slogs, reporter=sys.stdout )
# Load gtfsdb ==============================
for i, gtfsdb_filename in enumerate(gtfsdb_filenames):
gtfsdb = GTFSDatabase( gtfsdb_filename )
service_ids = [x.encode("ascii") for x in gtfsdb.service_ids()]
compiler.load_gtfsdb_to_boardalight_graph(g, str(i), gtfsdb, agency_id=agency_id, service_ids=service_ids)
if osmdb_filename:
compiler.load_transit_street_links_to_graph( g, osmdb, gtfsdb, reporter=sys.stdout )
if link_stations:
compiler.link_nearby_stops( g, gtfsdb )
# Export to graphdb ========================
graphdb = GraphDatabase( graphdb_filename, overwrite=True )
graphdb.populate( g, reporter=sys.stdout )
示例2: process_transit_graph
# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import populate [as 别名]
def process_transit_graph(gtfsdb_filename, agency_id, graphdb_filename, link=False):
gtfsdb = GTFSDatabase( gtfsdb_filename )
g = Graph()
service_ids = [x.encode("ascii") for x in gtfsdb.service_ids()]
compiler.load_gtfsdb_to_boardalight_graph(g, gtfsdb, agency_id=agency_id, service_ids=service_ids)
if link:
compiler.link_nearby_stops( g, gtfsdb )
graphdb = GraphDatabase( graphdb_filename, overwrite=True )
graphdb.populate( g, reporter=sys.stdout )
示例3: process_street_graph
# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import populate [as 别名]
def process_street_graph():
OSMDB_FILENAME = "ext/osm/bartarea.sqlite"
GRAPHDB_FILENAME = "bartstreets.db"
print( "Opening OSM-DB '%s'"%OSMDB_FILENAME )
osmdb = OSMDB( OSMDB_FILENAME )
g = Graph()
compiler.load_streets_to_graph( g, osmdb, sys.stdout )
graphdb = GraphDatabase( GRAPHDB_FILENAME, overwrite=True )
graphdb.populate( g, reporter=sys.stdout )
示例4: make_native_ch
# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import populate [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 )
示例5: main
# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import populate [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)
示例6: process_street_graph
# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import populate [as 别名]
def process_street_graph(osmdb_filename, graphdb_filename, profiledb_filename, slogs={}):
OSMDB_FILENAME = "ext/osm/bartarea.sqlite"
GRAPHDB_FILENAME = "bartstreets.db"
print( "Opening OSM-DB '%s'"%osmdb_filename )
osmdb = OSMDB( osmdb_filename )
if profiledb_filename:
print( "Opening ProfileDB '%s'"%profiledb_filename )
profiledb = ProfileDB( profiledb_filename )
else:
print( "No ProfileDB supplied" )
profiledb = None
g = Graph()
compiler.load_streets_to_graph( g, osmdb, profiledb, slogs, reporter=sys.stdout )
graphdb = GraphDatabase( graphdb_filename, overwrite=True )
graphdb.populate( g, reporter=sys.stdout )
示例7: process_transit_street_graph
# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import populate [as 别名]
def process_transit_street_graph(graphdb_filename, gtfsdb_filename, osmdb_filename, agency_id=None):
g = Graph()
# Load osmdb ===============================
print( "Opening OSM-DB '%s'"%osmdb_filename )
osmdb = OSMDB( osmdb_filename )
compiler.load_streets_to_graph( g, osmdb, sys.stdout )
# Load gtfsdb ==============================
for i, gtfsdb_filename in enumerate(gtfsdb_filenames):
gtfsdb = GTFSDatabase( gtfsdb_filename )
service_ids = [x.encode("ascii") for x in gtfsdb.service_ids()]
compiler.load_gtfsdb_to_boardalight_graph(g, str(i), gtfsdb, agency_id=agency_id, service_ids=service_ids)
compiler.load_transit_street_links_to_graph( g, osmdb, gtfsdb, reporter=sys.stdout )
# Export to graphdb ========================
graphdb = GraphDatabase( graphdb_filename, overwrite=True )
graphdb.populate( g, reporter=sys.stdout )
示例8: test_basic
# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import populate [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 )
示例9: test_ch
# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import populate [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 )