
    h=
                     \    d dl mZ d dlZd dlmZ d dlmZmZmZm	Z	 d dl
mZ d	dZd Zd Zy)
    )warnN)
MultiPoint)LINE_GEOM_TYPESPOLYGON_GEOM_TYPESfrom_shapelypoints_from_xy)	GeoSeriesc                 F   t         j                  j                  |      }| | j                  r
t	               S | j
                  t        v rt        | ||      S | j
                  t        v rt        | ||      S t        d| j
                   dt        d       t	               S )a  

    Sample uniformly at random from a geometry.

    For polygons, this samples uniformly within the area of the polygon. For lines,
    this samples uniformly along the length of the linestring. For multi-part
    geometries, the weights of each part are selected according to their relevant
    attribute (area for Polygons, length for LineStrings), and then points are
    sampled from each part uniformly.

    Any other geometry type (e.g. Point, GeometryCollection) are ignored, and an
    empty MultiPoint geometry is returned.

    Parameters
    ----------
    geom : any shapely.geometry.BaseGeometry type
        the shape that describes the area in which to sample.

    size : integer
        an integer denoting how many points to sample

    Returns
    -------
    shapely.MultiPoint geometry containing the sampled points

    Examples
    --------
    >>> from shapely.geometry import box
    >>> square = box(0,0,1,1)
    >>> uniform(square, size=102) # doctest: +SKIP
    )seed)size	generatorzSampling is not supported for z geometry type.   )
stacklevel)numpyrandomdefault_rngis_emptyr   	geom_typer   _uniform_polygonr   _uniform_liner   UserWarning)geomr   rngr   s       J/var/www/html/immo/lib/python3.12/site-packages/geopandas/tools/_random.pyuniformr      s    @ ((c(2I|t}}|~~++49EE~~(T	BB
((8H
 <    c                 z    |j                  |      }t        | j                  |d            j                         S )z/Sample points from an input shapely linestring.r   T)
normalized)r   r   interpolate	union_all)r   r   r   fracss       r   r   r   C   s9    4(E((4(@AKKMMr   c                    | j                   \  }}}}g }t        |      |k  rqt        |j                  |||      |j                  |||            }||j                  j                  | d         }	|j                  |	       t        |      |k  rq|j                  |       t        |d|       j                         S )z>Sample uniformly from within a polygon using batched sampling.r   )xycontains)	predicateN)
boundslenr   r   sindexqueryextendshuffler	   r!   )
r   r   r   xminyminxmaxymax
candidatesbatchvalid_sampless
             r   r   r   I   s    ![[D$dJ
j/D
 d6d6
 ell000LM-( j/D
  j!Z&'1133r   )N)warningsr   r   shapely.geometryr   geopandas.arrayr   r   r   r   geopandas.geoseriesr	   r   r   r    r   r   <module>r:      s.      '  *0fN4r   