From 967be9e750221ab2ab783f95df79bb26d290a45e Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:07:58 +0200 Subject: add: added projects --- ero1/src/drone/postier_chinois_montreal.py | 89 ++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 ero1/src/drone/postier_chinois_montreal.py (limited to 'ero1/src/drone/postier_chinois_montreal.py') diff --git a/ero1/src/drone/postier_chinois_montreal.py b/ero1/src/drone/postier_chinois_montreal.py new file mode 100644 index 0000000..04ade41 --- /dev/null +++ b/ero1/src/drone/postier_chinois_montreal.py @@ -0,0 +1,89 @@ +import osmnx as ox +import networkx as nx +import parameters as params + +from src.helper.debug_printer import debug_print +from src.helper.display_graph import display_graph +from src.helper.duplicate_removal import remove_duplicates +from src.helper.export_import_yaml import save_paths_to_yaml + +arrondissements = [ + 'Ahuntsic-Cartierville', + 'Anjou', + 'Côte-des-Neiges–Notre-Dame-de-Grâce', + 'Lachine', + 'LaSalle', + 'Le Plateau-Mont-Royal', + 'Le Sud-Ouest', + 'L\'Île-Bizard–Sainte-Geneviève', + 'Mercier–Hochelaga-Maisonneuve', + 'Montréal-Nord', + 'Outremont', + 'Pierrefonds-Roxboro', + 'Rivière-des-Prairies–Pointe-aux-Trembles', + 'Rosemont–La Petite-Patrie', + 'Saint-Laurent', + 'Saint-Léonard', + 'Verdun', + 'Ville-Marie', + 'Villeray–Saint-Michel–Parc-Extension' +] # first list, we changed its order manually to make a "smart path" for the drone + +connection_order = [ + 'Rivière-des-Prairies–Pointe-aux-Trembles', + 'Montréal-Nord', + 'Saint-Léonard', + 'Anjou', + 'Mercier–Hochelaga-Maisonneuve', + 'Rosemont–La Petite-Patrie', + 'Villeray–Saint-Michel–Parc-Extension', + 'Outremont', + 'Le Sud-Ouest', + 'Ville-Marie', + 'L\'Île-Bizard–Sainte-Geneviève', + 'Verdun', + 'LaSalle', + 'Côte-des-Neiges–Notre-Dame-de-Grâce', + 'Le Plateau-Mont-Royal', + 'Saint-Laurent', + 'Ahuntsic-Cartierville', + 'Pierrefonds-Roxboro', + 'Lachine' +] + +def find_circuit(G_undirected, debug_mode): + if nx.is_eulerian(G_undirected): + G_eulerian = G_undirected + else: + G_eulerian = nx.eulerize(G_undirected) + return nx.eulerian_circuit(G_eulerian), G_eulerian + +def generate_graph(name, debug_mode=False): + """ + permet de charger un graphe + d'une localisation a partir du nom de cette derniere. + """ + G = ox.graph_from_place(name, network_type='drive') + G = remove_duplicates(G, False) + G = ox.project_graph(G) + return G + +def process_graphs(Graphe_montreal, debug_mode): + """ + Création des paths + """ + paths = {} + debug_print(f"Génération : Montréal", debug_mode) + G_undirected = Graphe_montreal.to_undirected() + circuit, _ = find_circuit(G_undirected, debug_mode) + c = [edge for edge in circuit] + paths["Montréal"] = c + return paths + +def postier_chinois_process_montreal(Graphe_montreal, debug_mode): + paths = process_graphs(Graphe_montreal, debug_mode) + + # Save Path with YML + save_paths_to_yaml(paths, "paths-PostierChinoisMontreal.yml") + + return paths, finalPath -- cgit v1.2.3