Skip to content

Commit

Permalink
Added support for Point geometry.
Browse files Browse the repository at this point in the history
  • Loading branch information
iwatkot committed Jan 23, 2024
1 parent 690b03b commit 548037f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,13 +383,16 @@ def _to_polygon(self, obj: pd.core.series.Series, width: int | None) -> np.ndarr
return
return converter(geometry, width)

def _linestring(
self, geometry: shapely.geometry.linestring.LineString, width: int | None
def _sequence(
self,
geometry: shapely.geometry.linestring.LineString | shapely.geometry.point.Point,
width: int | None,
) -> np.ndarray:
"""Converts LineString geometry to numpy array of polygon points.
"""Converts LineString or Point geometry to numpy array of polygon points.
Args:
geometry (shapely.geometry.linestring.LineString): LineString geometry.
geometry (shapely.geometry.linestring.LineString | shapely.geometry.point.Point):
LineString or Point geometry.
width (int | None): Width of the polygon in meters.
Returns:
Expand All @@ -407,7 +410,7 @@ def _converters(self, geom_type: str) -> Callable[[shapely.geometry, int | None]
Returns:
Callable[[shapely.geometry, int | None], np.ndarray]: Converter function.
"""
converters = {"Polygon": self._to_np, "LineString": self._linestring}
converters = {"Polygon": self._to_np, "LineString": self._sequence, "Point": self._sequence}
return converters.get(geom_type)

def polygons(
Expand Down

0 comments on commit 548037f

Please sign in to comment.