From 4c68e5e1de4244497f8fcecc4166a9d895a6bdcf Mon Sep 17 00:00:00 2001 From: ViktorSemericov Date: Wed, 29 Oct 2025 19:32:05 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20route.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- route.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/route.py b/route.py index 7571f2a..29fc71d 100644 --- a/route.py +++ b/route.py @@ -4,13 +4,13 @@ import requests from typing import List, Tuple, Dict, Optional, Set import random class Point: - def __init__(self, coord: List[float], tag: str, visit_time: int): + def __init__(self, coord: List[float], tag: str, visit_time: int, list_id=0): self.coord = coord self.tag = tag self.visit_time = visit_time self.matrix_index = None # Индекс точки в матрице расстояний self.estimated_time = None # Оценочное время (перемещение + посещение) - + self.list_id = list_id def haversine(coord1: List[float], coord2: List[float]) -> float: """Calculate the great-circle distance between two points in kilometers.""" lat1, lon1 = coord1 @@ -248,8 +248,8 @@ def generate_routes_with_repeats(grouped_points: Dict[int, List[Point]], def form_point_list(data): point_list =[] - for entry in data: - point = Point(list(map(float,entry['coordinate'].split(', '))),entry['type'],entry['time_to_visit']) + for list_id,entry in enumerate(data): + point = Point(list(map(float,entry['coordinate'].split(', '))),entry['type'],entry['time_to_visit'],list_id) point_list.append(point) return point_list @@ -456,6 +456,7 @@ def build_route(data, mapping,start_coord,total_time,n_nodes,strategy='best'): print("All coordinates in the route are unique!") else: print("ERROR: Duplicate coordinates found in the route!") - return route_coords + places = [data[point.list_id] for point in optimal_route] + return route_coords,places #if __name__ == "__main__": # build_route() \ No newline at end of file