-
Notifications
You must be signed in to change notification settings - Fork 5
/
RouteOptions.py
100 lines (83 loc) · 3.67 KB
/
RouteOptions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Python 2.7
# MapQuest Inc.
"""Provides a container to hold route requests
"""
__author__ = '[email protected]'
import json
class RouteOptions(object):
"""
This class stores the options applicable to a directions or guidance
route request. More details at www.mapquestapi.com/directions/.
"""
def __init__(self, sessionId=None, unit='m', routeType='fastest',
avoidTimedConditions='false', doReverseGeocode='true', narrativeType='text',
enhancedNarrative='false', maxLinkId=0, locale='en_US', generalize=1.0, avoids=None,
disallows=None, prefers=None, mustAvoidLinkIds=None, tryAvoidLinkIds=None,
stateBoundaryDisplay=None, ctryBoundaryDisplay=None, cyclingRoadFactor=None,
roadGradeStrategy=None, drivingStyle=None, highwayEfficiency=None,
manMaps=None, walkingSpeed=None, fullShape=None, shapeFormat=None,
inShapeFormat=None, outShapeFormat=None):
self.routeOptions = dict()
self.key = None
if sessionId:
self.routeOptions['sessonId'] = sessionID
self.routeOptions['unit'] = unit
self.routeOptions['routeType'] = routeType
self.routeOptions['avoidTimedConditions'] = avoidTimedConditions
self.routeOptions['doReverseGeocode'] = doReverseGeocode
self.routeOptions['narrativeType'] = narrativeType
self.routeOptions['enhancedNarrative'] = enhancedNarrative
self.routeOptions['maxLinkId'] = maxLinkId
self.routeOptions['locale'] = locale
# advanced route options
if avoids:
self.routeOptions['avoids'] = avoids
if disallows:
self.routeOptions['disallows'] = disallows
if prefers:
self.routeOptions['prefers'] = prefers
if mustAvoidLinkIds:
self.routeOptions['mustAvoidLinkIds'] = mustAvoidLinkIds
if tryAvoidLinkIds:
self.routeOptions['tryAvoidLinkIds'] = tryAvoidLinkIds
if stateBoundaryDisplay:
self.routeOptions['stateBoundaryDisplay'] = stateBoundaryDisplay
if ctryBoundaryDisplay:
self.routeOptions['countryBoundaryDisplay'] = countryBoundaryDisplay
if cyclingRoadFactor:
self.routeOptions['cyclingRoadFactor'] = cyclingRoadFactor
if roadGradeStrategy:
self.routeOptions['roadGradeStrategy'] = roadGradeStrategy
if drivingStyle:
self.routeOptions['drivingStyle'] = drivingStyle
if highwayEfficiency:
self.routeOptions['highwayEfficiency'] = highwayEfficiency
if manMaps:
self.routeOptions['manMaps'] = manMaps
if walkingSpeed:
self.routeOptions['walkingSpeed'] = walkingSpeed
# route shape options
if fullShape:
self.routeOptions['fullShape'] = fullShape
if shapeFormat:
self.routeOptions['shapeFormat'] = shapeFormat
if inShapeFormat:
self.routeOptions['inShapeFormat'] = inShapeFormat
if outShapeFormat:
self.routeOptions['outShapeFormat'] = outShapeFormat
if generalize:
self.routeOptions['generalize'] = generalize
def setKey(self, key):
self.routeOptions['key'] = key
def setOrigin(self, origin):
self.routeOptions['from'] = origin
def setDestination(self, destination):
self.routeOptions['to'] = destination
def __repr__(self):
return str(self.routeOptions)
def __str__(self):
return str(self.routeOptions)
def getRouteOptions(self):
return self.routeOptions
def getRouteOptionsJSON(self):
return json.dumps(self.routeOptions)