
    1yi              	           d dl mZ dZ e ee            D  ci c]  } e|    | 
 c} Zdedeeeeef   fdZddedede	defd	Z
y
c c} w )    )Tuple 0123456789bcdefghjkmnpqrstuvwxyzgeohashreturnc                 \   d\  }}d\  }}d}| D ]z  }t         |   }dD ]j  }|r2|dz  }||z  r|d   |d   z   dz  |d   f}nE|d   |d   |d   z   dz  f}n1|dz  }||z  r|d   |d   z   dz  |d   f}n|d   |d   |d   z   dz  f}| }l | |d   |d   z   dz  }	|d   |d   z   dz  }
|	|
||fS )a  
    Decode the geohash to its exact values, including the error margins of the result.  Returns four float values:
    latitude, longitude, the plus/minus error for latitude (as a positive number) and the plus/minus error for longitude
    (as a positive number).
    )g     V     V@)g     f     f@)r	   r
   T               r   r   r   )	decodemap)r   lat_intervallon_intervallat_errlon_erris_longitudeccdmasklatlons              W/var/www/html/content_weaver/venv/lib/python3.12/site-packages/fakeredis/geo/geohash.py
geo_decoder   
   sC    "@L,"GWL ,q\$ 	,D19%a<?:a?$Q$L %Q%a<?:a?$L
 19%a<?:a?$Q$L %Q%a<?:a?$L  ,+L3	,,8 ?\!_,
1C?\!_,
1CWg%%    latitude	longitude	precisionc                   	
 d\  }}g g dc}
d\  	}d}dt         dt        t         t         f   dt        dt        t        t         t         f   t        f   f	
fd	}t        |      |k  rJ|r ||||      \  }}n || ||      \  }}| }	d
k  r	dz  	n|t        |   z  }d	d}t        |      |k  rJdj                  |      S )z
    Encode a position given in float arguments latitude, longitude to a geohash which will have the character count
    precision.
    r   r   )r   r   Tcurrintervalchr   c                 ^    |d   |d   z   dz  }| |kD  r|   z  }||d   f|fS |d   |f|fS )Nr   r   r    )r#   r$   r%   midbitbitss       r   next_intervalz!geo_encode.<locals>.next_interval>   sV    {Xa[(A-#:$s)OB!%r))QK%r))r   r   r   r    )floatr   intlenbase32join)r   r    r!   r   r   r   r%   r   r+   r)   r*   s            @@r   
geo_encoder2   4   s    
 "@L,(MGTGCL*E *U5%<-@ *c *eTYZ_afZfTgilTlNm * g,
",YbIL",X|RHL"''71HCvbz!GCB g,
" 777r   N)   )typingr   r0   ranger/   r   strr-   r   r.   r2   )is   0r   <module>r8      sy    	+#(V#56aVAY\6	'& '&eUE5&@ A '&T 5 S # [ 7s   A