
    Nwg                     :    d dl mZ d dlmZ d Zd Zd Zd Zd Zy)	    )WGS_84_SRID)SpatialErrorc                 :    t        | d      st        d| z        | S )zP
    Makes sure the parameter passed in looks like a GEOS ``GEOSGeometry``.
    	geom_typez0Point '%s' doesn't appear to be a GEOS geometry.)hasattrr   geoms    I/var/www/horilla/myenv/lib/python3.12/site-packages/haystack/utils/geo.pyensure_geometryr      s%     4%MPTTUUK    c                 V    t        |        | j                  dk7  rt        d| z        | S )zI
    Makes sure the parameter passed in looks like a GEOS ``Point``.
    Pointz(Provided geometry '%s' is not a 'Point'.)r   r   r   r   s    r
   ensure_pointr      s.     D~~ ELMMKr   c                     t        |        | j                         }|j                  st        |_        |S |j                  t        k7  r|j	                  t               |S )z}
    Ensures the point passed in is a GEOS ``Point`` & returns that point's
    data is in the WGS-84 spatial reference.
    )r   clonesridr   	transform)point	new_points     r
   ensure_wgs84r      sQ    
  I>>$	
 	 
;	&K(r   c                 V    	 | j                    | S # t        $ r t        d| z        w xY w)zD
    Makes sure the parameter passed in is a 'Distance' object.
    z/'%s' does not appear to be a 'Distance' object.)kmAttributeErrorr   )dists    r
   ensure_distancer   /   s<    U 	 K  ULtSTTUs    (c                 ~    | j                   \  }}|j                   \  }}t        ||      t        ||      }}||f||ffS )z
    Takes two opposite corners of a bounding box (order matters!) & generates
    a two-tuple of the correct coordinates for the bounding box.

    The two-tuple is in the form ``((min_lat, min_lng), (max_lat, max_lng))``.
    )coordsminmax)bottom_left	top_rightwestlat_1eastlat_2min_latmax_lats           r
   generate_bounding_boxr(   =   sL     $$KD%""KD%5%(#eU*;WGdOgt_--r   N)	haystack.constantsr   haystack.exceptionsr   r   r   r   r   r(    r   r
   <module>r,      s$    * ,	(
.r   