o
    i                     @   s:   d Z ddlmZ ddlmZ ddlmZ G dd dZdS )zK
This object provides quoting for GEOS geometries into PostgreSQL/PostGIS.
    )to_pgraster)GEOSGeometry)sqlc                   @   sJ   e Zd ZdddZdd Zdd Zdd	 Zd
d Zedd Z	dd Z
dS )PostGISAdapterFc                 C   s@   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    r   n/var/www/html/formularioweb/env/lib/python3.10/site-packages/django/contrib/gis/db/backends/postgis/adapter.py__init__   s   

zPostGISAdapter.__init__c                 C   s    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   r   r   r   __conform__   s   zPostGISAdapter.__conform__c                 C   s   t |to
| j|jkS N)r   r   r	   )r   otherr   r   r   __eq__&   s   zPostGISAdapter.__eq__c                 C   s
   t | jS r   )hashr	   r   r   r   r   __hash__)   s   
zPostGISAdapter.__hash__c                 C   s   |    S r   )	getquoteddecoder   r   r   r   __str__,   s   zPostGISAdapter.__str__c                 C   s   |S r   r   )clspolyr   r   r   _fix_polygon/   s   zPostGISAdapter._fix_polygonc                 C   s:   | j rd| jr	dndt| j f S d| j   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   r   r   r   r   3   s   zPostGISAdapter.getquotedN)F)__name__
__module____qualname__r   r   r   r   r   classmethodr!   r   r   r   r   r   r   
   s    

r   N)__doc__/django.contrib.gis.db.backends.postgis.pgrasterr   django.contrib.gis.geosr   )django.db.backends.postgresql.psycopg_anyr   r   r   r   r   r   <module>   s
    