Skip to content

Commit 4ce378b

Browse files
[ADD] Trucking features
1 parent 76d6336 commit 4ce378b

File tree

2 files changed

+54
-25
lines changed

2 files changed

+54
-25
lines changed

route4me/base.py

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,9 @@ def limited_weight_t(self, limited_weight_t):
329329
:param limited_weight_t:
330330
:return:
331331
"""
332-
if isinstance(limited_weight_t, types.LongType) or isinstance(limited_weight_t,
333-
types.IntType):
332+
if isinstance(limited_weight_t, types.LongType) or \
333+
isinstance(limited_weight_t, float) or \
334+
isinstance(limited_weight_t, types.IntType):
334335
self._copy_data({'limited_weight_t': limited_weight_t})
335336
else:
336337
raise ParamValueException('limited_weight_t', 'Must be integer or long')
@@ -341,47 +342,51 @@ def weight_per_axle_t(self, weight_per_axle_t):
341342
:param weight_per_axle_t:
342343
:return:
343344
"""
344-
if isinstance(weight_per_axle_t, types.LongType) or isinstance(weight_per_axle_t,
345-
types.IntType):
345+
if isinstance(weight_per_axle_t, types.LongType) or \
346+
isinstance(weight_per_axle_t, float) or \
347+
isinstance(weight_per_axle_t, types.IntType):
346348
self._copy_data({'weight_per_axle_t': weight_per_axle_t})
347349
else:
348350
raise ParamValueException('weight_per_axle_t', 'Must be integer or long')
349351

350-
def truck_height_meters(self, truck_height_meters):
352+
def truck_height(self, truck_height):
351353
"""
352-
Set truck_height_meters param
353-
:param truck_height_meters:
354+
Set truck_height param
355+
:param truck_height:
354356
:return:
355357
"""
356-
if isinstance(truck_height_meters, types.LongType) or isinstance(truck_height_meters,
357-
types.IntType):
358-
self._copy_data({'truck_height_meters': truck_height_meters})
358+
if isinstance(truck_height, types.LongType) or \
359+
isinstance(truck_height, float) or \
360+
isinstance(truck_height, types.IntType):
361+
self._copy_data({'truck_height': truck_height})
359362
else:
360-
raise ParamValueException('truck_height_meters', 'Must be integer or long')
363+
raise ParamValueException('truck_height', 'Must be integer or long')
361364

362-
def truck_width_meters(self, truck_width_meters):
365+
def truck_width(self, truck_width):
363366
"""
364-
Set truck_width_meters param
365-
:param truck_width_meters:
367+
Set truck_width param
368+
:param truck_width:
366369
:return:
367370
"""
368-
if isinstance(truck_width_meters, types.LongType) or isinstance(truck_width_meters,
369-
types.IntType):
370-
self._copy_data({'truck_width_meters': truck_width_meters})
371+
if isinstance(truck_width, types.LongType) or \
372+
isinstance(truck_width, float) or \
373+
isinstance(truck_width, types.IntType):
374+
self._copy_data({'truck_width': truck_width})
371375
else:
372-
raise ParamValueException('truck_width_meters', 'Must be integer or long')
376+
raise ParamValueException('truck_width', 'Must be integer or long')
373377

374-
def truck_length_meters(self, truck_length_meters):
378+
def truck_length(self, truck_length):
375379
"""
376-
Set truck_length_meters param
377-
:param truck_length_meters:
380+
Set truck_length param
381+
:param truck_length:
378382
:return:
379383
"""
380-
if isinstance(truck_length_meters, types.LongType) or isinstance(truck_length_meters,
381-
types.IntType):
382-
self._copy_data({'truck_length_meters': truck_length_meters})
384+
if isinstance(truck_length, types.LongType) or \
385+
isinstance(truck_length, float) or \
386+
isinstance(truck_length, types.IntType):
387+
self._copy_data({'truck_length': truck_length})
383388
else:
384-
raise ParamValueException('truck_length_meters', 'Must be integer or long')
389+
raise ParamValueException('truck_length', 'Must be integer or long')
385390

386391
def min_tour_size(self, min_tour_size):
387392
"""
@@ -789,3 +794,13 @@ def add(self, params={}, data={}):
789794
self.data.update(data)
790795
self.params.update(params)
791796

797+
def truck_hazardous_goods(self, truck_hazardous_goods):
798+
"""
799+
Set truck_hazardous_goods param
800+
:param truck_hazardous_goods:
801+
:return:
802+
"""
803+
if truck_hazardous_goods in TRUCK_HAZARDOUS_GOODS.reverse_mapping.keys():
804+
self._copy_data({'truck_hazardous_goods': truck_hazardous_goods})
805+
else:
806+
raise ParamValueException('truck_hazardous_goods', 'Must be MI or KM')

route4me/constants.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,17 @@ def auto_enum(*sequential, **named):
6161
UTURN = auto_enum('UTURN_DEPART_SHORTEST', 'UTURN_DEPART_TO_RIGHT')
6262

6363
LEFT_TURN = auto_enum('LEFTTURN_ALLOW', 'LEFTTURN_FORBID', 'LEFTTURN_MULTIAPPROACH')
64+
65+
TRUCK_HAZARDOUS_GOODS = enum(NONE='',
66+
EXPLOSIVE='explosive',
67+
GAS='gas',
68+
FLAMMABLE='flammable',
69+
COMBUSTIBLE='combustible',
70+
ORGANIC='organic',
71+
POISON='poison',
72+
RADIOACTIVE='radioActive',
73+
CORROSIVE='corrosive',
74+
POISONOUSINHALATION='poisonousInhalation',
75+
HARMFULTOWATER='harmfulToWater',
76+
OTHER='other',
77+
ALLHAZARDOUSGOODS='allHazardousGoods')

0 commit comments

Comments
 (0)