improve graph building, save graph after building it and split of drawgraph

This commit is contained in:
Laura Klünder 2016-12-05 12:09:43 +01:00
parent 6df2b7e3b7
commit a7ad682cbe
6 changed files with 116 additions and 28 deletions

View file

@ -1,3 +1,5 @@
import time
from django.core.management.base import BaseCommand
from c3nav.routing.graph import Graph
@ -6,18 +8,14 @@ from c3nav.routing.graph import Graph
class Command(BaseCommand):
help = 'build the routing graph'
def add_arguments(self, parser):
parser.add_argument('--draw-graph', action='store_const', const=True, default=False,
help='render a graph image')
parser.add_argument('--dont-draw-graph-points', action='store_const', const=True, default=False,
help='dont draw points on the graph image')
parser.add_argument('--dont-draw-graph-lines', action='store_const', const=True, default=False,
help='dont draw lines on the graph image')
def handle(self, *args, **options):
graph = Graph()
graph.build()
if options['draw_graph']:
graph.draw_pngs(points=not options['dont_draw_graph_points'], lines=not options['dont_draw_graph_lines'])
start = time.time()
graph.save()
print('Saved in %.4fs' % (time.time()-start))
start = time.time()
graph.load()
print('Loaded in %.4fs' % (time.time() - start))

View file

@ -0,0 +1,18 @@
from django.core.management.base import BaseCommand
from c3nav.routing.graph import Graph
class Command(BaseCommand):
help = 'graw the routing graph'
def add_arguments(self, parser):
parser.add_argument('--no-points', action='store_const', dest='points', const=False, default=True,
help='dont draw points on the graph image')
parser.add_argument('--no-lines', action='store_const', dest='lines', const=False, default=True,
help='dont draw lines on the graph image')
def handle(self, *args, **options):
graph = Graph.load()
graph.draw_pngs(points=options['points'], lines=options['lines'])