
    	i                     H    d Z ddlmZ ddlmZ ddlmZ  G d d          ZdS )zK
This object provides quoting for GEOS geometries into PostgreSQL/PostGIS.
    )to_pgraster)GEOSGeometry)sqlc                   J    e Zd Zd
dZd Zd Zd Zd Zed             Z	d Z
d	S )PostGISAdapterFc                     t          |t          t          f          | _        | j        rt	          |j                  | _        nt          |          | _        |j        | _        || _        dS )z3
        Initialize on the spatial object.
        N)	
isinstancer   r   is_geometrybytesewkbr   srid	geography)selfobjr   s      f/srv/django_bis/venv311/lib/python3.11/site-packages/django/contrib/gis/db/backends/postgis/adapter.py__init__zPostGISAdapter.__init__   s\     &cL.+IJJ  	)chDII#C((DIH	"    c                 <    ddl m} ||k    r| S t          d          )z9Does the given protocol conform to what Psycopg2 expects?r   )	ISQLQuotez<Error implementing psycopg2 protocol. Is psycopg2 installed?)psycopg2.extensionsr   	Exception)r   protor   s      r   __conform__zPostGISAdapter.__conform__   s9    111111IKN  r   c                 L    t          |t                    o| j        |j        k    S N)r	   r   r   )r   others     r   __eq__zPostGISAdapter.__eq__&   s     %00LTY%*5LLr   c                 *    t          | j                  S r   )hashr   r   s    r   __hash__zPostGISAdapter.__hash__)   s    DIr   c                 N    |                                                                  S r   )	getquoteddecoder    s    r   __str__zPostGISAdapter.__str__,   s    ~~&&(((r   c                     |S r    )clspolys     r   _fix_polygonzPostGISAdapter._fix_polygon/   s    r   c                     | j         r9d| j        rdndt          j        | j                                                  fz  S d| j                                                                        z  S )zP
        Return a properly quoted string for use in PostgreSQL/PostGIS.
        s   %s(%s)s   ST_GeogFromWKBs   ST_GeomFromEWKBs   '%s'::raster)r
   r   r   quoter   encodehexr    s    r   r#   zPostGISAdapter.getquoted3   sp      	>%)^K!!9K	$)$$++--    #TY]]__%;%;%=%===r   N)F)__name__
__module____qualname__r   r   r   r!   r%   classmethodr*   r#   r'   r   r   r   r   
   s        # # # # 	 	 	M M M  ) ) )   [> > > > >r   r   N)__doc__/django.contrib.gis.db.backends.postgis.pgrasterr   django.contrib.gis.geosr   )django.db.backends.postgresql.psycopg_anyr   r   r'   r   r   <module>r7      sz     H G G G G G 0 0 0 0 0 0 9 9 9 9 9 95> 5> 5> 5> 5> 5> 5> 5> 5> 5>r   