Skip to content

Commit 8b2088d

Browse files
authored
Merge pull request #437 from Labelbox/al-1518
AL-1518 - update to allow tiled image epsg transformer
2 parents d4570e2 + 5faff5a commit 8b2088d

File tree

3 files changed

+855
-806
lines changed

3 files changed

+855
-806
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: 392 additions & 423 deletions
Large diffs are not rendered by default.

labelbox/data/annotation_types/data/tiled_image.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
logging.basicConfig(level=logging.INFO)
2828
logger = logging.getLogger(__name__)
2929

30+
VectorTool = Union[Point, Line, Rectangle, Polygon]
31+
3032

3133
class EPSG(Enum):
3234
""" Provides the EPSG for tiled image assets that are currently supported.
@@ -355,8 +357,6 @@ def validate_zoom_levels(cls, zoom_levels):
355357
class EPSGTransformer(BaseModel):
356358
"""Transformer class between different EPSG's. Useful when wanting to project
357359
in different formats.
358-
359-
Requires as input a Point object.
360360
"""
361361

362362
class Config:
@@ -509,11 +509,16 @@ def _get_point_obj(self, point) -> Point:
509509

510510
def __call__(
511511
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]
513515
if isinstance(shape, Point):
514516
return self._get_point_obj(shape)
515-
if isinstance(shape, Line) or isinstance(shape, Polygon):
517+
if isinstance(shape, Line):
516518
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])
517522
if isinstance(shape, Rectangle):
518523
return Rectangle(start=self._get_point_obj(shape.start),
519524
end=self._get_point_obj(shape.end))

0 commit comments

Comments
 (0)