
    hp                         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	 d e	j                         iZ e j                  d      Z G d d	e      Zy)
    N)GDALException)GEOSExceptionGEOSGeometry)Textarea)translationLANGUAGE_BIDIzdjango.contrib.gisc                       e Zd ZdZd Zd Zy)OpenLayersWidgetzA
    Render an OpenLayers map using the WKT of the geometry.
    c                    |r8| j                   j                  |       | j                   d   | j                   d<   nd| j                   d<   d| j                   d<   |rt        |t              r	 t	        |      }|r8|j                  j                         | j                  k7  r| j                  dk7  rd }| j                         | j                   d<   || j                   d	<   | j                   d	   j                  d
d      }d|z  | j                   d<   |rd| j                   d   }|j                  |k7  r+	 |j                  }|j                  |       |j                   }n|j                   }|| j                   d<   | j                   j                  t$               | j                   S # t
        t        f$ r$}t        j                  d||       d }Y d }~Vd }~ww xY w# t"        $ r.}t        j                  d|j                  ||       d}Y d }~d }~ww xY w)N
modifiableeditableT wktz,Error creating geometry from value '%s' (%s)GEOMETRYmap_optionsname-_zgeodjango_%smodulesridz<Error transforming geometry from srid '%s' to srid '%s' (%s))paramsupdate
isinstancestrr   r   
ValueErrorloggererror	geom_typeupperr   replacer   ogr	transformr   r   geo_context)	selfr   valueattrserrjs_safe_namer   r!   r   s	            c/var/www/html/ranktracker/api/venv/lib/python3.12/site-packages/django/contrib/gis/admin/widgets.pyget_contextzOpenLayersWidget.get_context   s   KKu%&*kk,&?DKK
#&*DKK
#
  E Zs+$U+
 eoo++-?*,E &*%5%5%7M"
 #F {{6*223< . =H ;;v&DzzT!	))CMM$'''C ii "%DKK;'{{W ":. KUTWX: % LLV

D# Cs0   ,F /)G G.GG	H$HHc           
         d }d }ddddt         fddt        fdd	d
t        fddt        fddt        fg}i }|D ]  \  }}}| j                  j	                  |d      s$|dk(  r || j                  |         }n[|dk(  r || j                  |         }n@|t        t        fv r| j                  |   }n"|t         fv rd| j                  |   z  }nt
        |||<    |S )z7Build the map options hash for the OpenLayers template.c                     d| z  S )Nznew OpenLayers.Bounds(%s) )extents    r)   	ol_boundsz/OpenLayersWidget.map_options.<locals>.ol_boundsT   s    .77    c                     d| z  S )Nz$new OpenLayers.Projection("EPSG:%s")r-   )r   s    r)   ol_projectionz3OpenLayersWidget.map_options.<locals>.ol_projectionW   s    9D@@r0   )r   
projectionr   )display_sriddisplayProjectionr   unitsmax_resolutionmaxResolution)
max_extent	maxExtentboundsnum_zoomnumZoomLevelsmax_zoommaxZoomLevelsmin_zoomminZoomLevelFr   r;   z"%s")r   floatintr   get	TypeError)	r$   r/   r2   	map_typesr   
param_namejs_nameoption_typer%   s	            r)   r   zOpenLayersWidget.map_optionsQ   s   	8	A
 4Bw,&?: /37 /37 .#6	 09 	-,J{{z51&()$++j*ABE H,%dkk*&=>E UCL0 KK
3E SF*"T[[%<<E#O',G$	- r0   N)__name__
__module____qualname____doc__r*   r   r-   r0   r)   r
   r
      s    =~$r0   r
   )loggingdjango.contrib.gis.gdalr   django.contrib.gis.geosr   r   django.forms.widgetsr   django.utilsr   get_language_bidir#   	getLoggerr   r
   r-   r0   r)   <module>rU      sM     1 ? ) $  = = = ?@			/	0gx gr0   