a
    J5d                     @   s   d Z ddlZddlmZ ddlZddlZddlmZ ddl	m
Z
mZ ddlmZ ddlmZmZmZ g dZdd	d
Zdd Zdd ZG dd dZG dd dZG dd dejZG dd deZG dd dZG dd deZdS )a  Base geometry class and utilities

Note: a third, z, coordinate value may be used when constructing
geometry objects, but has no effect on geometric analysis. All
operations are performed in the x-y plane. Thus, geometries with
different z values may intersect or be equal.
    N)warn)_geom_factory)BufferCapStyleBufferJoinStyle)CoordinateSequence)GeometryTypeErrorGEOSExceptionShapelyDeprecationWarning)Point
LineString
LinearRingPolygonZ
MultiPointZMultiLineStringZMultiPolygonGeometryCollectionc                 C   s   t dtdd t| S )a  
    Creates a Shapely geometry instance from a pointer to a GEOS geometry.

    .. warning::
        The GEOS library used to create the the GEOS geometry pointer
        and the GEOS library used by Shapely must be exactly the same, or
        unexpected results or segfaults may occur.

    .. deprecated:: 2.0
        Deprecated in Shapely 2.0, and will be removed in a future version.
    zaThe 'geom_factory' function is deprecated in Shapely 2.0, and will be removed in a future version   
stacklevel)r   DeprecationWarningr   )gparent r   Q/var/www/html/django/DPS/env/lib/python3.9/site-packages/shapely/geometry/base.pygeom_factory   s    r   c                 C   s   t | tstd| jj nz| jdv r4| jdd S | jdkr^| jjdd dd | jD  S | j	dst| jdkrd	d | j
D S td
t| j dS )z@Dump coordinates of a geometry in the same order as data packingz,Must be instance of a geometry class; found )r
   r   r   Nr   c                 S   s   g | ]}|j d d  qS N)coords).0ir   r   r   
<listcomp>=       zdump_coords.<locals>.<listcomp>ZMultir   c                 S   s   g | ]}t |qS r   )dump_coords)r   partr   r   r   r   @   r   zUnhandled geometry type: )
isinstanceBaseGeometry
ValueError	__class____name__	geom_typer   ZexteriorZ	interiors
startswithgeomsr   repr)Zgeomr   r   r   r   4   s    



 r   c                 C   s   | j dkr|  S | S d S )Nr   )ndimitem)resultr   r   r   _maybe_unpackE   s    
r,   c                   @   s   e Zd ZejZejZejZdS )	CAP_STYLEN)r$   
__module____qualname__r   roundZflatZsquarer   r   r   r   r-   N   s   r-   c                   @   s   e Zd ZejZejZejZdS )
JOIN_STYLEN)r$   r.   r/   r   r0   ZmitreZbevelr   r   r   r   r1   T   s   r1   c                       s  e Zd ZdZg Zdd Zedd Zdd Zdd	 Z	d
d Z
 fddZdd Zdd Zdd Zdd Zdd Zdd Zedd Zedd Zedd Zd d! Zed"d# Zed$d% Zed&d' Zed(d) Zdd+d,Zd-d. Zed/d0 Zed1d2 Zd3d4 Zd5d6 Zed7d8 Z ed9d: Z!ed;d< Z"ed=d> Z#ed?d@ Z$dAdB Z%dCdD Z&edEdF Z'edGdH Z(edIdJ Z)edKdL Z*ddQdRZ+ddTdUZ,dVdW Z-ddYdZZ.dd[d\Z/dd]d^Z0dd_d`Z1edadb Z2edcdd Z3ededf Z4edgdh Z5edidj Z6edkdl Z7dmdn Z8dodp Z9dqdr Z:dsdt Z;dudv Z<dwdx Z=dydz Z>d{d| Z?d}d~ Z@dd ZAdd ZBdd ZCdd ZDdd ZEdddZFdd ZGdddZHdddZIdddZJdddZKdd ZLdd ZM  ZNS )r!   zG
    Provides GEOS spatial predicates and topological operations.

    c                 C   s   t dtdd tdS )NzDirectly calling the base class 'BaseGeometry()' is deprecated, and will raise an error in the future. To create an empty geometry, use one of the subclasses instead, for example 'GeometryCollection()'.r   r   GEOMETRYCOLLECTION EMPTYr   r	   shapelyZfrom_wktselfr   r   r   __new__b   s    zBaseGeometry.__new__c                 C   s
   t | S r   )r4   Zget_coordinate_dimensionr5   r   r   r   _ndiml   s    zBaseGeometry._ndimc                 C   s
   | j du S NFis_emptyr5   r   r   r   __bool__p   s    zBaseGeometry.__bool__c                 C   s   |   S r   )r<   r5   r   r   r   __nonzero__s   s    zBaseGeometry.__nonzero__c                 C   s   |dkrt j| ddS |dkr0t j| dd S |dkrFt j| ddS d}t||}|d	u rltd
| | \}}|rt|}nd}|sd}|dv rt j| |dd}n:|dv rt j| |dd}n |dv rtdnt	d| |
 r| S |S d	S )z/Format a geometry using a format specification. rounding_precisionxThexXz0(?:0?\.(?P<prec>[0-9]+))?(?P<fmt_code>[fFgGxX]?)Nzinvalid format specifier: r   )r   G)rA   Ztrim)fFF)rB   rE   z-hex representation does not specify precisionzunhandled fmt_code: )r4   to_wktto_wkblowerre	fullmatchr"   groupsintNotImplementedErrorisupperupper)r6   format_specZformat_spec_regexpmatchprecZfmt_coderesr   r   r   
__format__v   s6    

zBaseGeometry.__format__c              	      sh   zt   }W n$ ttfy2   d| jj Y S 0 d}t||kr\d|d |d   dS d| dS )Nz$<shapely.{} Exception in WKT writer>N   <   z...>>)super__str__r   r"   formatr#   r$   len)r6   wkt
max_lengthr#   r   r   __repr__   s    
zBaseGeometry.__repr__c                 C   s   | j S r   )r`   r5   r   r   r   r]      s    zBaseGeometry.__str__c                 C   s   t jt j| ddffS )NT)Zinclude_srid)r4   Zfrom_wkbrJ   r5   r   r   r   
__reduce__   s    zBaseGeometry.__reduce__c                 C   s
   |  |S r   )intersectionr6   otherr   r   r   __and__   s    zBaseGeometry.__and__c                 C   s
   |  |S r   )unionrf   r   r   r   __or__   s    zBaseGeometry.__or__c                 C   s
   |  |S r   )
differencerf   r   r   r   __sub__   s    zBaseGeometry.__sub__c                 C   s
   |  |S r   )symmetric_differencerf   r   r   r   __xor__   s    zBaseGeometry.__xor__c                 C   s   t j| | jd}t|S )z5Access to geometry's coordinates (CoordinateSequence))Z	include_z)r4   Zget_coordinateshas_zr   )r6   Zcoords_arrayr   r   r   r      s    zBaseGeometry.coordsc                 C   s   t dS )z,Separate arrays of X and Y coordinate valuesNrP   r5   r   r   r   xy   s    zBaseGeometry.xyc                 C   s   t dS )z)Dictionary representation of the geometryNrp   r5   r   r   r   __geo_interface__   s    zBaseGeometry.__geo_interface__c                 C   s   t dtdd | jS )Nz|The 'GeometryType()' method is deprecated, and will be removed in the future. You can use the 'geom_type' attribute instead.r   r   r   r	   r%   r5   r   r   r   geometryType   s    zBaseGeometry.geometryTypec                 C   s   t dtdd | jS )NzuThe 'type' attribute is deprecated, and will be removed in the future. You can use the 'geom_type' attribute instead.r   r   rs   r5   r   r   r   type   s    zBaseGeometry.typec                 C   s   t j| ddS )z"WKT representation of the geometryr?   r@   )r4   rI   r5   r   r   r   r`      s    zBaseGeometry.wktc                 C   s
   t | S )z"WKB representation of the geometryr4   rJ   r5   r   r   r   wkb   s    zBaseGeometry.wkbc                 C   s   t j| ddS )z&WKB hex representation of the geometryTrC   rv   r5   r   r   r   wkb_hex   s    zBaseGeometry.wkb_hex      ?c                 K   s   t dS )zRaises NotImplementedErrorNrp   )r6   scale_factorkwargsr   r   r   svg  s    zBaseGeometry.svgc              
   C   s<  d}| j r|d S | j\}}}}||krF||krF| dj\}}}}n@d}t|| || g}|| }||8 }||8 }||7 }||7 }|| }	|| }
ttd|	gdg}ttd|
gdg}zt|	|
gt||g }W n ty   d}Y n0 | d| d|	 d|
 }d	||  d
}|d||||| | S dS )z'SVG representation for iPython notebookzS<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" z/>   g{Gz?g      Y@i,  ry    zmatrix(1,0,0,-1,0,)zkwidth="{1}" height="{2}" viewBox="{0}" preserveAspectRatio="xMinYMin meet"><g transform="{3}">{4}</g></svg>N)r;   boundsbuffermaxminZeroDivisionErrorr^   r|   )r6   Zsvg_topZxminZyminZxmaxZymaxexpandZwidest_partZexpand_amountZdxZdywidthheightrz   Zview_boxZ	transformr   r   r   
_repr_svg_  s:    
zBaseGeometry._repr_svg_c                 C   s   t t|  S )z,Name of the geometry's type, such as 'Point')GEOMETRY_TYPESr4   Zget_type_idr5   r   r   r   r%   .  s    zBaseGeometry.geom_typec                 C   s   t t| S )z%Unitless area of the geometry (float))floatr4   arear5   r   r   r   r   6  s    zBaseGeometry.areac                 C   s   t t| |S )z+Unitless distance to other geometry (float))r,   r4   distancerf   r   r   r   r   ;  s    zBaseGeometry.distancec                 C   s   t t| |S )z5Unitless hausdorff distance to other geometry (float))r,   r4   hausdorff_distancerf   r   r   r   r   ?  s    zBaseGeometry.hausdorff_distancec                 C   s   t t| S )z'Unitless length of the geometry (float))r   r4   lengthr5   r   r   r   r   C  s    zBaseGeometry.lengthc                 C   s   t t| S )zWUnitless distance by which a node could be moved to produce an invalid geometry (float))r   r4   minimum_clearancer5   r   r   r   r   H  s    zBaseGeometry.minimum_clearancec                 C   s
   t | S )zReturns a lower dimension geometry that bounds the object

        The boundary of a polygon is a line, the boundary of a line is a
        collection of points. The boundary of a point is an empty (null)
        collection.
        )r4   boundaryr5   r   r   r   r   P  s    zBaseGeometry.boundaryc                 C   s   t t|  S )z8Returns minimum bounding region (minx, miny, maxx, maxy))tupler4   r   tolistr5   r   r   r   r   Z  s    zBaseGeometry.boundsc                 C   s
   t | S )z*Returns the geometric center of the object)r4   centroidr5   r   r   r   r   _  s    zBaseGeometry.centroidc                 C   s
   t | S )zoReturns a point guaranteed to be within the object, cheaply.

        Alias of `representative_point`.
        r4   point_on_surfacer5   r   r   r   r   d  s    zBaseGeometry.point_on_surfacec                 C   s
   t | S )zkReturns a point guaranteed to be within the object, cheaply.

        Alias of `point_on_surface`.
        r   r5   r   r   r   representative_pointk  s    z!BaseGeometry.representative_pointc                 C   s
   t | S )zImagine an elastic band stretched around the geometry: that's a
        convex hull, more or less

        The convex hull of a three member multipoint, for example, is a
        triangular polygon.
        )r4   convex_hullr5   r   r   r   r   r  s    zBaseGeometry.convex_hullc                 C   s
   t | S )z$A figure that envelopes the geometry)r4   enveloper5   r   r   r   r   |  s    zBaseGeometry.envelopec                 C   s
   t | S )an  
        Returns the oriented envelope (minimum rotated rectangle) that
        encloses the geometry.

        Unlike envelope this rectangle is not constrained to be parallel to the
        coordinate axes. If the convex hull of the object is a degenerate (line
        or point) this degenerate is returned.

        Alias of `minimum_rotated_rectangle`.
        r4   oriented_enveloper5   r   r   r   r     s    zBaseGeometry.oriented_envelopec                 C   s
   t | S )ah  
        Returns the oriented envelope (minimum rotated rectangle) that
        encloses the geometry.

        Unlike `envelope` this rectangle is not constrained to be parallel to the
        coordinate axes. If the convex hull of the object is a degenerate (line
        or point) this degenerate is returned.

        Alias of `oriented_envelope`.
        r   r5   r   r   r   minimum_rotated_rectangle  s    z&BaseGeometry.minimum_rotated_rectangle   r0         @Fc              	   K   s   | dd}|dur"tdt |}| dd}	|	dur:|	}|r^t| d }
td|
 d|dkrptd	nt|	 std
t
j| ||||||dS )a!  Get a geometry that represents all points within a distance
        of this geometry.

        A positive distance produces a dilation, a negative distance an
        erosion. A very small or zero distance may sometimes be used to
        "tidy" a polygon.

        Parameters
        ----------
        distance : float
            The distance to buffer around the object.
        resolution : int, optional
            The resolution of the buffer around each vertex of the
            object.
        quad_segs : int, optional
            Sets the number of line segments used to approximate an
            angle fillet.
        cap_style : shapely.BufferCapStyle or {'round', 'square', 'flat'}, default 'round'
            Specifies the shape of buffered line endings. BufferCapStyle.round ('round')
            results in circular line endings (see ``quad_segs``). Both BufferCapStyle.square
            ('square') and BufferCapStyle.flat ('flat') result in rectangular line endings,
            only BufferCapStyle.flat ('flat') will end at the original vertex,
            while BufferCapStyle.square ('square') involves adding the buffer width.
        join_style : shapely.BufferJoinStyle or {'round', 'mitre', 'bevel'}, default 'round'
            Specifies the shape of buffered line midpoints. BufferJoinStyle.ROUND ('round')
            results in rounded shapes. BufferJoinStyle.bevel ('bevel') results in a beveled
            edge that touches the original vertex. BufferJoinStyle.mitre ('mitre') results
            in a single vertex that is beveled depending on the ``mitre_limit`` parameter.
        mitre_limit : float, optional
            The mitre limit ratio is used for very sharp corners. The
            mitre ratio is the ratio of the distance from the corner to
            the end of the mitred offset corner. When two line segments
            meet at a sharp angle, a miter join will extend the original
            geometry. To prevent unreasonable geometry, the mitre limit
            allows controlling the maximum length of the join corner.
            Corners with a ratio which exceed the limit will be beveled.
        single_side : bool, optional
            The side used is determined by the sign of the buffer
            distance:

                a positive distance indicates the left-hand side
                a negative distance indicates the right-hand side

            The single-sided buffer of point geometries is the same as
            the regular buffer.  The End Cap Style for single-sided
            buffers is always ignored, and forced to the equivalent of
            CAP_FLAT.
        quadsegs : int, optional
            Deprecated alias for `quad_segs`.

        Returns
        -------
        Geometry

        Notes
        -----
        The return value is a strictly two-dimensional geometry. All
        Z coordinates of the original geometry will be ignored.

        Examples
        --------
        >>> from shapely.wkt import loads
        >>> g = loads('POINT (0.0 0.0)')

        16-gon approx of a unit radius circle:

        >>> g.buffer(1.0).area  # doctest: +ELLIPSIS
        3.1365484905459...

        128-gon approximation:

        >>> g.buffer(1.0, 128).area  # doctest: +ELLIPSIS
        3.141513801144...

        triangle approximation:

        >>> g.buffer(1.0, 3).area
        3.0
        >>> list(g.buffer(1.0, cap_style=BufferCapStyle.square).exterior.coords)
        [(1.0, 1.0), (1.0, -1.0), (-1.0, -1.0), (-1.0, 1.0), (1.0, 1.0)]
        >>> g.buffer(1.0, cap_style=BufferCapStyle.square).area
        4.0

        quadsegsNz?The `quadsegs` argument is deprecated. Use `quad_segs` instead.
resolutionr   z-buffer() got an unexpected keyword argument ''g        z3Cannot compute offset from zero-length line segmentzbuffer distance must be finite)	quad_segs	cap_style
join_stylemitre_limitsingle_sided)popr   FutureWarninglistkeys	TypeErrorr"   npisfiniteallr4   r   )r6   r   r   r   r   r   r   r{   r   r   kwargr   r   r   r     s4    ^
zBaseGeometry.bufferTc                 C   s   t j| ||dS )a[  Returns a simplified geometry produced by the Douglas-Peucker
        algorithm

        Coordinates of the simplified geometry will be no more than the
        tolerance distance from the original. Unless the topology preserving
        option is used, the algorithm may produce self-intersecting or
        otherwise invalid geometries.
        )preserve_topology)r4   simplify)r6   	tolerancer   r   r   r   r     s    	zBaseGeometry.simplifyc                 C   s
   t | S )a  Converts geometry to normal form (or canonical form).

        This method orders the coordinates, rings of a polygon and parts of
        multi geometries consistently. Typically useful for testing purposes
        (for example in combination with `equals_exact`).

        Examples
        --------
        >>> from shapely import MultiLineString
        >>> line = MultiLineString([[(0, 0), (1, 1)], [(3, 3), (2, 2)]])
        >>> line.normalize()
        <MULTILINESTRING ((2 2, 3 3), (0 0, 1 1))>
        )r4   	normalizer5   r   r   r   r   %  s    zBaseGeometry.normalizeNc                 C   s   t j| ||dS )zz
        Returns the difference of the geometries.

        Refer to `shapely.difference` for full documentation.
        	grid_size)r4   rk   r6   rg   r   r   r   r   rk   8  s    zBaseGeometry.differencec                 C   s   t j| ||dS )z~
        Returns the intersection of the geometries.

        Refer to `shapely.intersection` for full documentation.
        r   )r4   re   r   r   r   r   re   @  s    zBaseGeometry.intersectionc                 C   s   t j| ||dS )z
        Returns the symmetric difference of the geometries.

        Refer to `shapely.symmetric_difference` for full documentation.
        r   )r4   rm   r   r   r   r   rm   H  s    z!BaseGeometry.symmetric_differencec                 C   s   t j| ||dS )zp
        Returns the union of the geometries.

        Refer to `shapely.union` for full documentation.
        r   )r4   ri   r   r   r   r   ri   P  s    zBaseGeometry.unionc                 C   s   t t| S )zWTrue if the geometry's coordinate sequence(s) have z values (are
        3-dimensional))boolr4   ro   r5   r   r   r   ro   [  s    zBaseGeometry.has_zc                 C   s   t t| S )z?True if the set of points in this geometry is empty, else False)r   r4   r;   r5   r   r   r   r;   a  s    zBaseGeometry.is_emptyc                 C   s   t t| S )z1True if the geometry is a closed ring, else False)r   r4   is_ringr5   r   r   r   r   f  s    zBaseGeometry.is_ringc                 C   s   | j dkrdS tt| S )zVTrue if the geometry is closed, else False

        Applicable only to 1-D geometries.r   T)r%   r   r4   	is_closedr5   r   r   r   r   k  s    
zBaseGeometry.is_closedc                 C   s   t t| S )zsTrue if the geometry is simple, meaning that any self-intersections
        are only at boundary points, else False)r   r4   	is_simpler5   r   r   r   r   t  s    zBaseGeometry.is_simplec                 C   s   t t| S )zSTrue if the geometry is valid (definition depends on sub-class),
        else False)r   r4   is_validr5   r   r   r   r   z  s    zBaseGeometry.is_validc                 C   s   t | |S )zNReturns the DE-9IM intersection matrix for the two geometries
        (string))r4   relaterf   r   r   r   r     s    zBaseGeometry.relatec                 C   s   t t| |S )z9Returns True if the geometry covers the other, else False)r,   r4   coversrf   r   r   r   r     s    zBaseGeometry.coversc                 C   s   t t| |S )z@Returns True if the geometry is covered by the other, else False)r,   r4   
covered_byrf   r   r   r   r     s    zBaseGeometry.covered_byc                 C   s   t t| |S )z;Returns True if the geometry contains the other, else False)r,   r4   containsrf   r   r   r   r     s    zBaseGeometry.containsc                 C   s   t t| |S )z
        Returns True if the geometry completely contains the other, with no
        common boundary points, else False

        Refer to `shapely.contains_properly` for full documentation.
        )r,   r4   contains_properlyrf   r   r   r   r     s    zBaseGeometry.contains_properlyc                 C   s   t t| |S )z0Returns True if the geometries cross, else False)r,   r4   crossesrf   r   r   r   r     s    zBaseGeometry.crossesc                 C   s   t t| |S )z3Returns True if geometries are disjoint, else False)r,   r4   disjointrf   r   r   r   r     s    zBaseGeometry.disjointc                 C   s   t t| |S )a  Returns True if geometries are equal, else False.

        This method considers point-set equality (or topological
        equality), and is equivalent to (self.within(other) &
        self.contains(other)).

        Examples
        --------
        >>> LineString(
        ...     [(0, 0), (2, 2)]
        ... ).equals(
        ...     LineString([(0, 0), (1, 1), (2, 2)])
        ... )
        True

        Returns
        -------
        bool

        )r,   r4   equalsrf   r   r   r   r     s    zBaseGeometry.equalsc                 C   s   t t| |S )z0Returns True if geometries intersect, else False)r,   r4   
intersectsrf   r   r   r   r     s    zBaseGeometry.intersectsc                 C   s   t t| |S )z.Returns True if geometries overlap, else False)r,   r4   overlapsrf   r   r   r   r     s    zBaseGeometry.overlapsc                 C   s   t t| |S )z,Returns True if geometries touch, else False)r,   r4   touchesrf   r   r   r   r     s    zBaseGeometry.touchesc                 C   s   t t| |S )z8Returns True if geometry is within the other, else False)r,   r4   withinrf   r   r   r   r     s    zBaseGeometry.withinc                 C   s   t t| ||S )z
        Returns True if geometry is within a given distance from the other, else False.

        Refer to `shapely.dwithin` for full documentation.
        )r,   r4   dwithin)r6   rg   r   r   r   r   r     s    zBaseGeometry.dwithinc                 C   s   t t| ||S )aW  True if geometries are equal to within a specified
        tolerance.

        Parameters
        ----------
        other : BaseGeometry
            The other geometry object in this comparison.
        tolerance : float
            Absolute tolerance in the same units as coordinates.

        This method considers coordinate equality, which requires
        coordinates to be equal and in the same order for all components
        of a geometry.

        Because of this it is possible for "equals()" to be True for two
        geometries and "equals_exact()" to be False.

        Examples
        --------
        >>> LineString(
        ...     [(0, 0), (2, 2)]
        ... ).equals_exact(
        ...     LineString([(0, 0), (1, 1), (2, 2)]),
        ...     1e-6
        ... )
        False

        Returns
        -------
        bool

        )r,   r4   equals_exact)r6   rg   r   r   r   r   r     s    !zBaseGeometry.equals_exact   c                 C   s$   t dtdd | |dd|   S )a  True if geometries are equal at all coordinates to a
        specified decimal place.

        .. deprecated:: 1.8.0
            The 'almost_equals()' method is deprecated
            and will be removed in Shapely 2.1 because the name is
            confusing. The 'equals_exact()' method should be used
            instead.

        Refers to approximate coordinate equality, which requires
        coordinates to be approximately equal and in the same order for
        all components of a geometry.

        Because of this it is possible for "equals()" to be True for two
        geometries and "almost_equals()" to be False.

        Examples
        --------
        >>> LineString(
        ...     [(0, 0), (2, 2)]
        ... ).equals_exact(
        ...     LineString([(0, 0), (1, 1), (2, 2)]),
        ...     1e-6
        ... )
        False

        Returns
        -------
        bool

        zkThe 'almost_equals()' method is deprecated and will be removed in Shapely 2.1; use 'equals_exact()' insteadr   r   g      ?
   )r   r	   r   )r6   rg   decimalr   r   r   almost_equals  s     zBaseGeometry.almost_equalsc                 C   s   t t| ||S )z|Returns True if the DE-9IM string code for the relationship between
        the geometries satisfies the pattern, else False)r,   r4   relate_pattern)r6   rg   patternr   r   r   r     s    zBaseGeometry.relate_patternc                 C   s   t j| ||dS )zReturns the distance along this geometry to a point nearest the
        specified point

        If the normalized arg is True, return the distance normalized to the
        length of the linear geometry.

        Alias of `project`.
        
normalizedr4   line_locate_pointr6   rg   r   r   r   r   r   '  s    	zBaseGeometry.line_locate_pointc                 C   s   t j| ||dS )zReturns the distance along this geometry to a point nearest the
        specified point

        If the normalized arg is True, return the distance normalized to the
        length of the linear geometry.

        Alias of `line_locate_point`.
        r   r   r   r   r   r   project2  s    	zBaseGeometry.projectc                 C   s   t j| ||dS )a  Return a point at the specified distance along a linear geometry

        Negative length values are taken as measured in the reverse
        direction from the end of the geometry. Out-of-range index
        values are handled by clamping them to the valid range of values.
        If the normalized arg is True, the distance will be interpreted as a
        fraction of the geometry's length.

        Alias of `interpolate`.
        r   r4   line_interpolate_pointr6   r   r   r   r   r   r   =  s    z#BaseGeometry.line_interpolate_pointc                 C   s   t j| ||dS )a  Return a point at the specified distance along a linear geometry

        Negative length values are taken as measured in the reverse
        direction from the end of the geometry. Out-of-range index
        values are handled by clamping them to the valid range of values.
        If the normalized arg is True, the distance will be interpreted as a
        fraction of the geometry's length.

        Alias of `line_interpolate_point`.
        r   r   r   r   r   r   interpolateJ  s    zBaseGeometry.interpolatec                 C   s   t | |S )a  Adds vertices to line segments based on maximum segment length.

        Additional vertices will be added to every line segment in an input geometry
        so that segments are no longer than the provided maximum segment length. New
        vertices will evenly subdivide each segment.

        Only linear components of input geometries are densified; other geometries
        are returned unmodified.

        Parameters
        ----------
        max_segment_length : float or array_like
            Additional vertices will be added so that all line segments are no
            longer this value.  Must be greater than 0.

        Examples
        --------
        >>> from shapely import LineString, Polygon
        >>> LineString([(0, 0), (0, 10)]).segmentize(max_segment_length=5)
        <LINESTRING (0 0, 0 5, 0 10)>
        >>> Polygon([(0, 0), (10, 0), (10, 10), (0, 10), (0, 0)]).segmentize(max_segment_length=5)
        <POLYGON ((0 0, 5 0, 10 0, 10 5, 10 10, 5 10, 0 10, 0 5, 0 0))>
        )r4   
segmentize)r6   Zmax_segment_lengthr   r   r   r   W  s    zBaseGeometry.segmentizec                 C   s
   t | S )aO  Returns a copy of this geometry with the order of coordinates reversed.

        If the geometry is a polygon with interior rings, the interior rings are also
        reversed.

        Points are unchanged.

        See also
        --------
        is_ccw : Checks if a geometry is clockwise.

        Examples
        --------
        >>> from shapely import LineString, Polygon
        >>> LineString([(0, 0), (1, 2)]).reverse()
        <LINESTRING (1 2, 0 0)>
        >>> Polygon([(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)]).reverse()
        <POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))>
        )r4   reverser5   r   r   r   r   q  s    zBaseGeometry.reverse)ry   )r   r0   r0   r   F)T)N)N)N)N)r   )F)F)F)F)Or$   r.   r/   __doc__	__slots__r7   propertyr8   r<   r=   rW   rc   r]   rd   rh   rj   rl   rn   r   rq   rr   rt   ru   r`   rw   rx   r|   r   r%   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rk   re   rm   ri   ro   r;   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __classcell__r   r   rb   r   r!   Z   s   

-


	
	



'




	


	


     
}










	#
(



r!   c                   @   s:   e Zd Zg Zedd Zedd Zdd Zdd	d
ZdS )BaseMultipartGeometryc                 C   s   t dd S )NzNSub-geometries may have coordinate sequences, but multi-part geometries do notrp   r5   r   r   r   r     s    zBaseMultipartGeometry.coordsc                 C   s   t | S r   )GeometrySequencer5   r   r   r   r'     s    zBaseMultipartGeometry.geomsc                 C   s
   | j du S r9   r:   r5   r   r   r   r<     s    zBaseMultipartGeometry.__bool__ry   Nc                    sD   | j r
dS  du r | jrdnd dd fdd| jD  d	 S )
az  Returns a group of SVG elements for the multipart geometry.

        Parameters
        ==========
        scale_factor : float
            Multiplication factor for the SVG stroke-width.  Default is 1.
        color : str, optional
            Hex string for stroke or fill color. Default is to use "#66cc99"
            if geometry is valid, and "#ff3333" if invalid.
        z<g />Nz#66cc99z#ff3333z<g>r>   c                 3   s   | ]}|  V  qd S r   )r|   )r   pcolorrz   r   r   	<genexpr>  r   z,BaseMultipartGeometry.svg.<locals>.<genexpr>z</g>)r;   r   joinr'   )r6   rz   r   r   r   r   r|     s
    zBaseMultipartGeometry.svg)ry   N)	r$   r.   r/   r   r   r   r'   r<   r|   r   r   r   r   r     s   

r   c                   @   s<   e Zd ZdZdZdd Zdd Zdd Zd	d
 Zdd Z	dS )r   zJ
    Iterative access to members of a homogeneous multipart geometry.
    Nc                 C   s
   || _ d S r   )_parent)r6   r   r   r   r   __init__  s    zGeometrySequence.__init__c                 C   s   t | j|S r   )r4   Zget_geometryr   r6   r   r   r   r   _get_geom_item  s    zGeometrySequence._get_geom_itemc                 c   s"   t |  D ]}| |V  qd S r   )range__len__r   r   r   r   r   __iter__  s    zGeometrySequence.__iter__c                 C   s   t | jS r   )r4   Zget_num_geometriesr   r5   r   r   r   r     s    zGeometrySequence.__len__c                 C   s   |   }t|ttjfrT|| dk s,||kr4td|dk rF|| }n|}| |S t|trg }||\}}}t	|||D ]}|
| | q~t| j|pd S tdd S )Nr   zindex out of rangezkey must be an index or slice)r   r    rO   r   integer
IndexErrorr   sliceindicesr   appendru   r   r   )r6   keymr   rV   startstopZstrider   r   r   __getitem__  s    


zGeometrySequence.__getitem__)
r$   r.   r/   r   r   r   r   r   r   r   r   r   r   r   r     s   r   c                   @   s   e Zd Zdd ZdS )EmptyGeometryc                 C   s   t dtdd tdS )zCreate an empty geometry.zThe 'EmptyGeometry()' constructor to create an empty geometry is deprecated, and will raise an error in the future. Use one of the geometry subclasses instead, for example 'GeometryCollection()'.r   r   r2   r3   r5   r   r   r   r7     s    zEmptyGeometry.__new__N)r$   r.   r/   r7   r   r   r   r   r     s   r   )N)r   rL   warningsr   numpyr   r4   Zshapely._geometry_helpersr   Zshapely.constructiver   r   Zshapely.coordsr   Zshapely.errorsr   r   r	   r   r   r   r,   r-   r1   ZGeometryr!   r   r   r   r   r   r   r   <module>   s0   
	      4$,