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