Exemple #1
0
from opentripplanner import RoutingRequest, Graph
from opentripplanner.batch import BatchProcessor, PointSet
import time

init_time = time.time()

# Set the parameters for our search
r = RoutingRequest()
r.dateTime = 1449496800  # Monday, Dec. 7th, 2014, 7:00 am EST (doesn't matter for a walking search)
r.setModes('WALK,TRANSIT')

print 'routing request set in %g seconds' % (time.time() - init_time)

# read the graph
g = Graph('/home/clayton/otp/graphs/nyc/', 'nyc')

print 'graph read at %g seconds (cumulative time)' % (time.time() - init_time)

# read the destinations
# do this before running the batch processor, so that if there is an error reading the destinations, we don't have to wait for
# the batch processor to finish
destinations = PointSet('zcta_wac.shp')
print 'destinations read at %g seconds (cumulative time)' % (time.time() -
                                                             init_time)

# Link the destinations to the graph
# In theory this is done automatically, but the automatic linking happens after the searches have happened
# This shouldn't be a problem, but due to OTP bug #1577, it needs to happen before searches are run
destinations.link(g)
print 'destinations linked at %g seconds (cumulative time)' % (time.time() -
 def setGraph(self, graph):
     if isinstance(graph, str):
         self._graph = Graph(graph)
     else:
         self._graph = graph