Skip to content

Commit

Permalink
Fields padding fix
Browse files Browse the repository at this point in the history
  • Loading branch information
iwatkot authored Dec 24, 2024
1 parent b5d9dda commit 29f2c75
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 7 additions & 3 deletions maps4fs/generator/texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def draw(self) -> None:

mask = cv2.bitwise_not(cumulative_image)

for polygon in self.polygons(layer.tags, layer.width): # type: ignore
for polygon in self.polygons(layer.tags, layer.width, layer.info_layer): # type: ignore
if layer.info_layer:
info_layer_data[layer.info_layer].append(self.np_to_polygon_points(polygon))
cv2.fillPoly(layer_image, [polygon], color=255) # type: ignore
Expand Down Expand Up @@ -621,18 +621,22 @@ def _converters(
return converters.get(geom_type) # type: ignore

def polygons(
self, tags: dict[str, str | list[str] | bool], width: int | None
self,
tags: dict[str, str | list[str] | bool],
width: int | None,
info_layer: str | None = None,
) -> Generator[np.ndarray, None, None]:
"""Generator which yields numpy arrays of polygons from OSM data.
Arguments:
tags (dict[str, str | list[str]]): Dictionary of tags to search for.
width (int | None): Width of the polygon in meters (only for LineString).
info_layer (str | None): Name of the corresponding info layer.
Yields:
Generator[np.ndarray, None, None]: Numpy array of polygon points.
"""
is_fieds = "farmland" in tags.values()
is_fieds = info_layer == "fields"
try:
objects = ox.features_from_bbox(bbox=self.new_bbox, tags=tags)
except Exception as e: # pylint: disable=W0718
Expand Down
5 changes: 5 additions & 0 deletions webui/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,11 @@ def generate_map(self) -> None:
st.session_state.generated = True

self.status_container.success("Map generation completed!", icon="✅")
except Exception as e:
self.logger.error("An error occurred while generating the map: %s", repr(e))
self.status_container.error(
f"An error occurred while generating the map: {repr(e)}.", icon="❌"
)
finally:
if self.community:
remove_from_queue(session_name)
Expand Down

0 comments on commit 29f2c75

Please sign in to comment.