13
13
from typing_extensions import Literal
14
14
from typing import (Any , List , Optional , BinaryIO , Dict , Iterable , Tuple , Union ,
15
15
Type , Set )
16
- from shapely .geometry import Polygon as SPolygon , Point as SPoint , LineString , box # type: ignore
17
16
18
17
import labelbox
19
18
from labelbox import utils
@@ -65,7 +64,6 @@ def _make_request_data(project_id: str, name: str, content_length: int,
65
64
def _send_create_file_command (
66
65
client , request_data : dict , file_name : str ,
67
66
file_data : Tuple [str , Union [bytes , BinaryIO ], str ]) -> dict :
68
-
69
67
response = requests .post (
70
68
client .endpoint ,
71
69
headers = {"authorization" : "Bearer %s" % client .api_key },
@@ -717,9 +715,6 @@ def is_geom_valid(cls, v):
717
715
f"A polygon must have at least 3 points to be valid. Found { v } " )
718
716
return v
719
717
720
- def to_shapely_poly (self ) -> SPolygon :
721
- return SPolygon ([[point .x , point .y ] for point in self .polygon ])
722
-
723
718
724
719
class NDPolyline (NDBaseTool ):
725
720
ontology_type : Literal ["line" ] = "line"
@@ -732,32 +727,18 @@ def is_geom_valid(cls, v):
732
727
f"A line must have at least 2 points to be valid. Found { v } " )
733
728
return v
734
729
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
-
739
730
740
731
class NDRectangle (NDBaseTool ):
741
732
ontology_type : Literal ["rectangle" ] = "rectangle"
742
733
bbox : Bbox = pydantic .Field (determinant = True )
743
-
744
734
#Could check if points are positive
745
735
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
-
751
736
752
737
class NDPoint (NDBaseTool ):
753
738
ontology_type : Literal ["point" ] = "point"
754
739
point : Point = pydantic .Field (determinant = True )
755
-
756
740
#Could check if points are positive
757
741
758
- def to_shapely_poly (self , buffer = 70. ) -> SPolygon :
759
- return SPoint ([self .point .x , self .point .y ]).buffer (buffer )
760
-
761
742
762
743
class EntityLocation (BaseModel ):
763
744
start : int
0 commit comments