
    df                     J    d dl mZ d dlmZmZ d dlmZ  G d de          ZdS )    )
WKTAdapter)GeometryCollectionPolygon)oracledbc                   f    e Zd Zej        Zd Zed             Ze	dd            Z
e	d             ZdS )OracleSpatialAdapterc                 B    t          |t                    r+                     |          r                     |          }nEt          |t                    r0t           fd|D                       r                     |          }|j         _        |j         _        dS )a  
        Oracle requires that polygon rings are in proper orientation. This
        affects spatial operations and an invalid orientation may cause
        failures. Correct orientations are:
         * Outer ring - counter clockwise
         * Inner ring(s) - clockwise
        c              3   l   K   | ].}t          |t                    o                    |          V  /d S N)
isinstancer   _polygon_must_be_fixed).0gselfs     iD:\Python Project\djangoTemplates\venv\Lib\site-packages\django/contrib/gis/db/backends/oracle/adapter.py	<genexpr>z0OracleSpatialAdapter.__init__.<locals>.<genexpr>   sQ        NO
1g&&I4+F+Fq+I+I         N)	r   r   r   _fix_polygonr   any_fix_geometry_collectionwktsrid)r   geoms   ` r   __init__zOracleSpatialAdapter.__init__	   s     dG$$ 	;**400 /((..011 	;    SW     ; 44T::8I			r   c                 ^    | j          o%| j        j         pt          d | D                       S )Nc              3   $   K   | ]}|j         V  d S r   )is_counterclockwise)r   xs     r   r   z>OracleSpatialAdapter._polygon_must_be_fixed.<locals>.<genexpr>!   s%      77Q1(777777r   )emptyexterior_ringr   r   )polys    r   r   z+OracleSpatialAdapter._polygon_must_be_fixed   s>    :~ 
"66 877$77777	
r   Tc                 :   |r|                                 }|j        j        s&t          t	          |j                            |_        t          dt          |                    D ]4}||         j        r%t          t	          ||                             ||<   5|S )z:Fix single polygon orientation as described in __init__().   )cloner    r   listreversedrangelen)clsr!   r$   is       r   r   z!OracleSpatialAdapter._fix_polygon$   s      	 ::<<D!5 	D!%ht/A&B&B!C!CDq#d))$$ 	2 	2AAw* 2xQ0011Qr   c                     |                                 }t          |          D ]4\  }}t          |t                    r|                     |d          ||<   5|S )zf
        Fix polygon orientations in geometry collections as described in
        __init__().
        F)r$   )r$   	enumerater   r   r   )r)   collr*   r   s       r   r   z-OracleSpatialAdapter._fix_geometry_collection3   s^     zz||  	> 	>GAt$(( >**4u*==Qr   N)T)__name__
__module____qualname__r   CLOB
input_sizer   staticmethodr   classmethodr   r    r   r   r   r      s        J  ( 
 
 \
    [ 	 	 [	 	 	r   r   N)+django.contrib.gis.db.backends.base.adapterr   django.contrib.gis.geosr   r   &django.db.backends.oracle.oracledb_anyr   r   r5   r   r   <module>r9      su    B B B B B B ? ? ? ? ? ? ? ? ; ; ; ; ; ;7 7 7 7 7: 7 7 7 7 7r   