[P] Code cleanup.
This commit is contained in:
@@ -61,8 +61,9 @@ class Datasource:
|
||||
self.connection_status = "Disconnected"
|
||||
Logger.debug("SERVER DISCONNECT")
|
||||
|
||||
def map_lat_lon_to_ProcessedAgentData(self, lat: float, lon: float) -> ProcessedAgentData | None:
|
||||
distances = tuple((abs(lon - marker.latitude) ** 2 + abs(lat - marker.longitude) ** 2) ** 0.5 for marker in self._active_markers)
|
||||
def map_lat_lon_to_processed_agent_data(self, lat: float, lon: float) -> ProcessedAgentData | None:
|
||||
distances = tuple((abs(lon - marker.latitude) ** 2 + abs(lat - marker.longitude) ** 2) ** 0.5 for marker in
|
||||
self._active_markers)
|
||||
|
||||
if len(distances) == 0:
|
||||
return None
|
||||
|
||||
@@ -63,7 +63,7 @@ class MapViewApp(App):
|
||||
|
||||
# Оновлює лінію маршрута
|
||||
if user_id not in self.line_layers:
|
||||
self.line_layers[user_id] = LineMapLayer(color = line_layer_colors[user_id % len(line_layer_colors)])
|
||||
self.line_layers[user_id] = LineMapLayer(color=line_layer_colors[user_id % len(line_layer_colors)])
|
||||
self.mapview.add_layer(self.line_layers[user_id])
|
||||
|
||||
self.line_layers[user_id].add_point((lat, lon))
|
||||
@@ -109,7 +109,7 @@ class MapViewApp(App):
|
||||
|
||||
try:
|
||||
return next(flt)
|
||||
except StopIteration as e:
|
||||
except StopIteration:
|
||||
return None
|
||||
|
||||
def set_pothole_marker(self, point):
|
||||
@@ -145,14 +145,14 @@ class MapViewApp(App):
|
||||
if lat is None or lon is None:
|
||||
return
|
||||
|
||||
clicked_marker_data = self.datasource.map_lat_lon_to_ProcessedAgentData(lat, lon)
|
||||
clicked_marker_data = self.datasource.map_lat_lon_to_processed_agent_data(lat, lon)
|
||||
|
||||
if not clicked_marker_data:
|
||||
return
|
||||
|
||||
clicked_marker = self.map_lat_lon_to_marker(clicked_marker_data.latitude, clicked_marker_data.longitude)
|
||||
|
||||
if clicked_marker == None:
|
||||
if clicked_marker is None:
|
||||
return
|
||||
|
||||
self.mapview.remove_marker(clicked_marker)
|
||||
@@ -168,7 +168,6 @@ class MapViewApp(App):
|
||||
self.delete_pothole_marker(coordinate)
|
||||
return True
|
||||
|
||||
|
||||
def build(self):
|
||||
"""
|
||||
Ініціалізує мапу MapView(zoom, lat, lon)
|
||||
@@ -180,7 +179,7 @@ class MapViewApp(App):
|
||||
lon=30.5234
|
||||
)
|
||||
|
||||
self.mapview.bind(on_touch_down = self.on_touch_down)
|
||||
self.mapview.bind(on_touch_down=self.on_touch_down)
|
||||
|
||||
return self.mapview
|
||||
|
||||
|
||||
Reference in New Issue
Block a user