1313from typing_extensions import Literal
1414from typing import (Any , List , Optional , BinaryIO , Dict , Iterable , Tuple , Union ,
1515 Type , Set )
16- from shapely .geometry import Polygon as SPolygon , Point as SPoint , LineString , box # type: ignore
1716
1817import labelbox
1918from labelbox import utils
@@ -65,7 +64,6 @@ def _make_request_data(project_id: str, name: str, content_length: int,
6564def _send_create_file_command (
6665 client , request_data : dict , file_name : str ,
6766 file_data : Tuple [str , Union [bytes , BinaryIO ], str ]) -> dict :
68-
6967 response = requests .post (
7068 client .endpoint ,
7169 headers = {"authorization" : "Bearer %s" % client .api_key },
@@ -717,9 +715,6 @@ def is_geom_valid(cls, v):
717715 f"A polygon must have at least 3 points to be valid. Found { v } " )
718716 return v
719717
720- def to_shapely_poly (self ) -> SPolygon :
721- return SPolygon ([[point .x , point .y ] for point in self .polygon ])
722-
723718
724719class NDPolyline (NDBaseTool ):
725720 ontology_type : Literal ["line" ] = "line"
@@ -732,32 +727,18 @@ def is_geom_valid(cls, v):
732727 f"A line must have at least 2 points to be valid. Found { v } " )
733728 return v
734729
735- def to_shapely_poly (self , buffer = 70. ) -> SPolygon :
736- return LineString ([[point .x , point .y ] for point in self .line
737- ]).buffer (buffer )
738-
739730
740731class NDRectangle (NDBaseTool ):
741732 ontology_type : Literal ["rectangle" ] = "rectangle"
742733 bbox : Bbox = pydantic .Field (determinant = True )
743-
744734 #Could check if points are positive
745735
746- def to_shapely_poly (self ) -> SPolygon :
747- return box (self .bbox .left , self .bbox .top ,
748- self .bbox .left + self .bbox .width ,
749- self .bbox .top + self .bbox .height )
750-
751736
752737class NDPoint (NDBaseTool ):
753738 ontology_type : Literal ["point" ] = "point"
754739 point : Point = pydantic .Field (determinant = True )
755-
756740 #Could check if points are positive
757741
758- def to_shapely_poly (self , buffer = 70. ) -> SPolygon :
759- return SPoint ([self .point .x , self .point .y ]).buffer (buffer )
760-
761742
762743class EntityLocation (BaseModel ):
763744 start : int
0 commit comments