|
27 | 27 | logging.basicConfig(level=logging.INFO) |
28 | 28 | logger = logging.getLogger(__name__) |
29 | 29 |
|
| 30 | +VectorTool = Union[Point, Line, Rectangle, Polygon] |
| 31 | + |
30 | 32 |
|
31 | 33 | class EPSG(Enum): |
32 | 34 | """ Provides the EPSG for tiled image assets that are currently supported. |
@@ -355,8 +357,6 @@ def validate_zoom_levels(cls, zoom_levels): |
355 | 357 | class EPSGTransformer(BaseModel): |
356 | 358 | """Transformer class between different EPSG's. Useful when wanting to project |
357 | 359 | in different formats. |
358 | | -
|
359 | | - Requires as input a Point object. |
360 | 360 | """ |
361 | 361 |
|
362 | 362 | class Config: |
@@ -509,11 +509,16 @@ def _get_point_obj(self, point) -> Point: |
509 | 509 |
|
510 | 510 | def __call__( |
511 | 511 | self, shape: Union[Point, Line, Rectangle, Polygon] |
512 | | - ) -> Union[Point, Line, Rectangle, Polygon]: |
| 512 | + ) -> Union[VectorTool, List[VectorTool]]: |
| 513 | + if isinstance(shape, list): |
| 514 | + return [self(geom) for geom in shape] |
513 | 515 | if isinstance(shape, Point): |
514 | 516 | return self._get_point_obj(shape) |
515 | | - if isinstance(shape, Line) or isinstance(shape, Polygon): |
| 517 | + if isinstance(shape, Line): |
516 | 518 | return Line(points=[self._get_point_obj(p) for p in shape.points]) |
| 519 | + if isinstance(shape, Polygon): |
| 520 | + return Polygon( |
| 521 | + points=[self._get_point_obj(p) for p in shape.points]) |
517 | 522 | if isinstance(shape, Rectangle): |
518 | 523 | return Rectangle(start=self._get_point_obj(shape.start), |
519 | 524 | end=self._get_point_obj(shape.end)) |
|
0 commit comments