From 357387786f78298cde531ba7445c1521502e0a71 Mon Sep 17 00:00:00 2001 From: Stan Soldatov Date: Thu, 9 Jan 2025 00:47:22 +0100 Subject: [PATCH] Minor code updates. --- maps4fs/generator/component.py | 17 ++++------------- maps4fs/generator/texture.py | 14 +++++++------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/maps4fs/generator/component.py b/maps4fs/generator/component.py index 60c0eb6..ab3a310 100644 --- a/maps4fs/generator/component.py +++ b/maps4fs/generator/component.py @@ -188,7 +188,6 @@ def get_bbox( self, coordinates: tuple[float, float] | None = None, distance: int | None = None, - project_utm: bool = False, ) -> tuple[int, int, int, int]: """Calculates the bounding box of the map from the coordinates and the height and width of the map. @@ -199,7 +198,6 @@ def get_bbox( of the map. Defaults to None. distance (int, optional): The distance from the center of the map to the edge of the map in all directions. Defaults to None. - project_utm (bool, optional): Whether to project the bounding box to UTM. Returns: tuple[int, int, int, int]: The bounding box of the map. @@ -208,15 +206,15 @@ def get_bbox( distance = distance or int(self.map_rotated_size / 2) west, south, east, north = ox.utils_geo.bbox_from_point( # type: ignore - coordinates, dist=distance, project_utm=project_utm + coordinates, + dist=distance, ) bbox = north, south, east, west self.logger.debug( - "Calculated bounding box for component: %s: %s, project_utm: %s, distance: %s", + "Calculated bounding box for component: %s: %s, distance: %s", self.__class__.__name__, bbox, - project_utm, distance, ) return bbox @@ -225,7 +223,7 @@ def save_bbox(self) -> None: """Saves the bounding box of the map to the component instance from the coordinates and the height and width of the map. """ - self.bbox = self.get_bbox(project_utm=False) + self.bbox = self.get_bbox() self.logger.debug("Saved bounding box: %s", self.bbox) @property @@ -544,17 +542,10 @@ def get_z_scaling_factor(self) -> float: """ scaling_factor = 1 / self.map.dem_settings.multiplier - self.logger.debug("Z scaling factor including DEM multiplier: %s", scaling_factor) if self.map.shared_settings.height_scale_multiplier: scaling_factor *= self.map.shared_settings.height_scale_multiplier - self.logger.debug( - "Z scaling factor including height scale multiplier: %s", scaling_factor - ) if self.map.shared_settings.mesh_z_scaling_factor: scaling_factor *= 1 / self.map.shared_settings.mesh_z_scaling_factor - self.logger.debug( - "Z scaling factor including mesh z scaling factor: %s", scaling_factor - ) return scaling_factor diff --git a/maps4fs/generator/texture.py b/maps4fs/generator/texture.py index c450ed8..a8f3f37 100644 --- a/maps4fs/generator/texture.py +++ b/maps4fs/generator/texture.py @@ -336,7 +336,7 @@ def rotate_textures(self) -> None: # pylint: disable=W0201 def _read_parameters(self) -> None: """Reads map parameters from OSM data, such as: - - minimum and maximum coordinates in UTM format + - minimum and maximum coordinates - map dimensions in meters - map coefficients (meters per pixel) """ @@ -727,36 +727,36 @@ def objects_generator( yield from method(objects, width, is_fieds) def linestrings_generator( - self, objects_utm: pd.core.frame.DataFrame, *args, **kwargs + self, objects: pd.core.frame.DataFrame, *args, **kwargs ) -> Generator[list[tuple[int, int]], None, None]: """Generator which yields lists of point coordinates which represent LineStrings from OSM. Arguments: - objects_utm (pd.core.frame.DataFrame): Dataframe with OSM objects in UTM format. + objects (pd.core.frame.DataFrame): Dataframe with OSM objects. Yields: Generator[list[tuple[int, int]], None, None]: List of point coordinates. """ - for _, obj in objects_utm.iterrows(): + for _, obj in objects.iterrows(): geometry = obj["geometry"] if isinstance(geometry, shapely.geometry.linestring.LineString): points = [self.latlon_to_pixel(x, y) for y, x in geometry.coords] yield points def polygons_generator( - self, objects_utm: pd.core.frame.DataFrame, width: int | None, is_fieds: bool + self, objects: pd.core.frame.DataFrame, width: int | None, is_fieds: bool ) -> Generator[np.ndarray, None, None]: """Generator which yields numpy arrays of polygons from OSM data. Arguments: - objects_utm (pd.core.frame.DataFrame): Dataframe with OSM objects in UTM format. + objects (pd.core.frame.DataFrame): Dataframe with OSM objects. width (int | None): Width of the polygon in meters (only for LineString). is_fieds (bool): Flag to determine if the fields should be padded. Yields: Generator[np.ndarray, None, None]: Numpy array of polygon points. """ - for _, obj in objects_utm.iterrows(): + for _, obj in objects.iterrows(): try: polygon = self._to_polygon(obj, width) except Exception as e: # pylint: disable=W0703