88
99from rasters .wrap_geometry import wrap_geometry
1010from .CRS import CRS , WGS84
11- from .bbox import BBox
12- from .polygon import Polygon
11+ # from .bbox import BBox
12+ # from .polygon import Polygon
1313from .vector_geometry import VectorGeometry , SingleVectorGeometry
1414
1515
@@ -34,18 +34,21 @@ class Point(SingleVectorGeometry):
3434 >>> print(point.x, point.y, point.crs)
3535 10 20 WGS84
3636 """
37- def __init__ (self , * args , crs : Union [CRS , str ] = WGS84 ):
38- if isinstance (args [0 ], Point ):
37+ def __init__ (self , * args , crs : Union [CRS , str ] = WGS84 , x : float = None , y : float = None ):
38+ if len ( args ) > 0 and isinstance (args [0 ], Point ):
3939 # If the first argument is a Point, extract geometry and crs
4040 geometry = args [0 ].geometry
4141 crs = args [0 ].crs
42+ elif x is not None and y is not None :
43+ # If x and y are provided as keyword arguments
44+ geometry = shapely .geometry .Point (x , y )
4245 else :
43- # Otherwise, create a new shapely Point from the arguments
46+ # Otherwise, create a new shapely Point from the positional arguments
4447 geometry = shapely .geometry .Point (* args )
45-
48+
4649 # Initialize the base VectorGeometry class
4750 VectorGeometry .__init__ (self , crs = crs )
48-
51+
4952 self .geometry = geometry
5053
5154 @property
@@ -101,7 +104,7 @@ def buffer(
101104 cap_style = CAP_STYLE .round ,
102105 join_style = JOIN_STYLE .round ,
103106 mitre_limit = 5.0 ,
104- single_sided = False ) -> Polygon :
107+ single_sided = False ) -> " Polygon" :
105108 """
106109 Creates a buffer polygon around the point.
107110
@@ -117,6 +120,8 @@ def buffer(
117120 Returns:
118121 Polygon: The buffer polygon.
119122 """
123+ from .polygon import Polygon
124+
120125 # Create the buffer using shapely's buffer method
121126 buffer_geom = shapely .geometry .Point .buffer (
122127 self .geometry ,
@@ -132,13 +137,14 @@ def buffer(
132137 return Polygon (buffer_geom , crs = self .crs )
133138
134139 @property
135- def bbox (self ) -> BBox :
140+ def bbox (self ) -> " BBox" :
136141 """
137142 Returns the bounding box of the point.
138-
143+
139144 Returns:
140145 BBox: The bounding box of the point.
141146 """
147+ from .bbox import BBox
142148 return BBox (self .x , self .y , self .x , self .y , crs = self .crs )
143149
144150 def distance (self , other : Point ) -> float :
0 commit comments