
    jj                     2    S SK rSS jrS rS rSrS rS rg)	    N   c                     U R                   R                  5       U R                  5       R                  5       -  (       a  [        S5      eU R                  n[        X2U5      u  pE[        X$U5      nU$ )a  
Calculate the distance along a Hilbert curve.

The distances are calculated for the midpoints of the geometries in the
GeoDataFrame.

Parameters
----------
geoms : GeometryArray
total_bounds : 4-element array
    Total bounds of geometries - array
level : int (1 - 16), default 16
    Determines the precision of the curve (points on the curve will
    have coordinates in the range [0, 2^level - 1]).

Returns
-------
np.ndarray
    Array containing distances along the Hilbert curve

zTHilbert distance cannot be computed on a GeoSeries with empty or missing geometries.)is_emptyanyisna
ValueErrorbounds_continuous_to_discrete_coords_encode)geomstotal_boundslevelr	   xy	distancess          `/var/www/html/Sattelite-Image/venv/lib/python3.13/site-packages/geopandas/tools/hilbert_curve.py_hilbert_distancer      sg    , ~~ejjl..00"
 	

 \\F *&FDA!$I    c                 d   SU-  S-
  nU SS2S4   U SS2S4   -   S-  nU SS2S4   U SS2S4   -   S-  nUcV  [         R                  " U5      [         R                  " U5      [         R                  " U5      [         R                  " U5      4nUu  pgp[        XFU4U5      n
[        XWU	4U5      nX4$ )au  Calculate mid points & ranges of geoms and returns as discrete coords.

Parameters
----------
bounds : Bounds of each geometry - array

p : The number of iterations used in constructing the Hilbert curve

total_bounds : Total bounds of geometries - array

Returns
-------
Discrete two-dimensional numpy array
Two-dimensional array Array of hilbert distances for each geom

      Nr   g       @   )npnanminnanmax_continuous_to_discrete)r	   r   r   side_lengthx_midsy_midsxminyminxmaxymaxx_inty_ints               r   r
   r
   *   s    $ e8q.K QTlVAqD\)S0FQTlVAqD\)S0F IIfIIfIIfIIf	
 *D $F4L+FE#F4L+FE<r   c                     US   US   -
  nUS:X  a#  [         R                  " U [         R                  S9$ XS   -
  X#-  -  n[         R                  " USX$S9  UR	                  [         R                  5      $ )a$  Convert a continuous one-dimensional array to discrete integer values
based their ranges.

Parameters
----------
vals : Array of continuous values

val_range : Tuple containing range of continuous values

n : Number of discrete values

Returns
-------
One-dimensional array of discrete ints

r   r   dtype)out)r   
zeros_likeuint32clipastype)vals	val_rangenwidthress        r   r   r   T   sh    " aL9Q<'Ez}}T33A,19
-CGGCA::bii  r   c                 V    X S-  -  S-  n X S-  -  S-  n X S-  -  S-  n X S-  -  S-  n U $ )	N   i     ir   i3333r   iUUUU )r   s    r   _interleaver7   v   sG    	
1f#A	
1f#A	
1f#A	
1f#AHr   c                    [         R                  " USS9n[         R                  " USS9nU [        :  a  [        S5      eUSU -
  -  nUSU -
  -  nX-  nSU-  nSX-  -  nXS-  -  nX4S-	  -  nUS-	  U-  nUS-	  XFS-	  -  -  U-  n	X5S-	  -  US-	  -  U-  n
UR	                  5       nUR	                  5       nU	R	                  5       nU
R	                  5       nX3S-	  -  XDS-	  -  -  nX4S-	  -  XCU-  S-	  -  -  nXUS-	  -  XFS-	  -  -  -  n	XUS-	  -  X4-  US-	  -  -  -  n
UR	                  5       nUR	                  5       nU	R	                  5       nU
R	                  5       nX3S-	  -  XDS-	  -  -  nX4S-	  -  XCU-  S-	  -  -  nXUS-	  -  XFS-	  -  -  -  n	XUS-	  -  X4-  US-	  -  -  -  n
UR	                  5       nUR	                  5       nU	R	                  5       nU
R	                  5       nXUS	-	  -  XFS	-	  -  -  -  n	XUS	-	  -  X4-  US	-	  -  -  -  n
XS-	  -  nXS-	  -  nX-  nUSX-  -  -  n[        U5      S-  [        U5      -  S
SU -  -
  -	  $ )Nr+   r'   zLevel out of ranger   i  r   r   r5   r4       )r   asarray	MAX_LEVELr   copyr7   )r   r   r   abcdABCDi0i1s                r   r   r   ~   s   


1H%A


1H%Ay-..	b5jA	b5jA 	
A
A!%A	ZA	!VA	
a1A
q&Qq&\	"a'A
Av,16	"a'A	A	A	A	A	
1f!Av,'A	
1f!A!|,-AqAv,1Q<	((AqAv,AEa1f-	..A	A	A	A	A	
1f!Av,'A	
1f!A!|,-AqAv,1Q<	((AqAv,AEa1f-	..A 	
A	A	A	AqAv,1Q<	((AqAv,AEa1f-	..A 	
!VA	!VA 
B	
f	 B_![_4"q5y.IIr   )Nr   )numpyr   r   r
   r   r;   r7   r   r6   r   r   <module>rH      s+    #L'T!> 	:Jr   