MCPcopy Create free account
hub / github.com/AdaCompNUS/summit / cut

Method cut

PythonAPI/examples/gamma_crowd.py:470–488  ·  view source on GitHub ↗
(self, sumo_network, position)

Source from the content-addressed store, hash-verified

468 return min_offset
469
470 def cut(self, sumo_network, position):
471 cut_index = 0
472 min_offset = None
473 min_offset_index = None
474 for i in range(int(len(self.route_points) / 2)):
475 route_point = self.route_points[i]
476 offset = position - sumo_network.get_route_point_position(route_point)
477 offset = offset.length()
478 if min_offset == None or offset < min_offset:
479 min_offset = offset
480 min_offset_index = i
481 if offset <= 1.0:
482 cut_index = i + 1
483
484 # Invalid path because too far away.
485 if min_offset > 1.0:
486 self.route_points = self.route_points[min_offset_index:]
487 else:
488 self.route_points = self.route_points[cut_index:]
489
490 def get_position(self, sumo_network, index=0):
491 return sumo_network.get_route_point_position(self.route_points[index])

Callers

nothing calls this directly

Calls 1

lengthMethod · 0.80

Tested by

no test coverage detected