Commits

Rémy HUBSCHER committed 7fa17d5

On fusionne les lignes 3 parallèles pour rester dans le même bus

  • Participants
  • Parent commits ecec9da

Comments (0)

Files changed (2)

File optymize/api/handlers.py

             first = False
         else:
             # 3. Si le moyen de locomotion change :
-            if (current_is_bus != last_was_bus) or (current_is_bus and last_route != point.route):
+            if (current_is_bus != last_was_bus) or (current_is_bus and routes[last_route].line.number != routes[point.route].line.number):
                 if last_was_bus:
                     # 3.1 C'était une ligne de bus, on ajoute {'line': line, 'stops': stops}
                     line = routes[last_route].line

File optymize/dijkstra/utils.py

         if geopoint.station is not None:
             neighbours = self.geopoint.neighbours[geopoint.station.id]
 
-            for n in neighbours:
-                route = n.get('route', None)
-                if self.route is not None and route is not None and route != self.route:
-                    n['duration'] += 5
-
             self.geopoint.neighbours[geopoint.station.id] = sorted(neighbours, key=lambda k: k['duration'])
 
             info = [d for d in self.geopoint.neighbours[geopoint.station.id] if d['duration'] == min([p['duration'] for p in self.geopoint.neighbours[geopoint.station.id]])][0]
             return u'%s - %s' % ( self.distance, self.type)
 
     def neighbours(self):
-        # if self.parent:
-        #     for neighbours in self.geopoint.neighbours.values():
-        #         for neighbour in neighbours:
-        #             # Calcul des pénalités lors du changement de bus
-        #             route = neighbour.get('route', None)
-        #             if route and route != self.parent.route:
-        #                 neighbour['duration'] += 10
+        if self.parent:
+            for neighbours in self.geopoint.neighbours.values():
+                for neighbour in neighbours:
+                    # Calcul des pénalités lors du changement de bus
+                    route = neighbour.get('route', None)
+                    if route is not None and self.parent.route is not None and route != self.parent.route:
+                        neighbour['duration'] += 5
 
 
         keys = sorted(self.geopoint.neighbours.keys(), key=lambda k: min([d['duration'] for d in self.geopoint.neighbours[k]]))