Skip to content

Commit 743737b

Browse files
committed
update to allow tiled image epsg transformer to recursively call itself if thre is a list of objects
1 parent 0ab238d commit 743737b

File tree

3 files changed

+859
-680
lines changed

3 files changed

+859
-680
lines changed

examples/annotation_types/tiled_imagery_basics.ipynb

Lines changed: 454 additions & 379 deletions
Large diffs are not rendered by default.

examples/model_assisted_labeling/tiled_imagery_mal.ipynb

Lines changed: 393 additions & 297 deletions
Large diffs are not rendered by default.

labelbox/data/annotation_types/data/tiled_image.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
logger = logging.getLogger(__name__)
2929

3030

31+
class AllVectorTools():
32+
"""Used for the purpose of type hinting"""
33+
value: Union[Point, Line, Rectangle, Polygon] = None
34+
35+
3136
class EPSG(Enum):
3237
""" Provides the EPSG for tiled image assets that are currently supported.
3338
@@ -355,8 +360,6 @@ def validate_zoom_levels(cls, zoom_levels):
355360
class EPSGTransformer(BaseModel):
356361
"""Transformer class between different EPSG's. Useful when wanting to project
357362
in different formats.
358-
359-
Requires as input a Point object.
360363
"""
361364

362365
class Config:
@@ -509,11 +512,16 @@ def _get_point_obj(self, point) -> Point:
509512

510513
def __call__(
511514
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]
513518
if isinstance(shape, Point):
514519
return self._get_point_obj(shape)
515-
if isinstance(shape, Line) or isinstance(shape, Polygon):
520+
if isinstance(shape, Line):
516521
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])
517525
if isinstance(shape, Rectangle):
518526
return Rectangle(start=self._get_point_obj(shape.start),
519527
end=self._get_point_obj(shape.end))

0 commit comments

Comments
 (0)