
    +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dS )
    N)GDALException)GEOSExceptionGEOSGeometry)Textarea)translationLANGUAGE_BIDIzdjango.contrib.gisc                       e Zd ZdZd Zd ZdS )OpenLayersWidgetzA
    Render an OpenLayers map using the WKT of the geometry.
    c                    |r0| j                             |           | j         d         | j         d<   n
d| j         d<   d| j         d<   |rbt          |t                    rM	 t	          |          }n<# t
          t          f$ r(}t                              d||           d }Y d }~nd }~ww xY w|r/|j	        
                                | j	        k    r| j	        dk    rd }|                                 | j         d<   || j         d	<   | j         d	                             d
d          }d|z  | j         d<   |r| j         d         }|j        |k    r`	 |j        }|                    |           |j        }nB# t"          $ r.}t                              d|j        ||           d}Y d }~nd }~ww xY w|j        }|| j         d<   | j                             t$                     | j         S )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	            d/var/www/html/e360mart/e360mart_env/lib/python3.11/site-packages/django/contrib/gis/admin/widgets.pyget_contextzOpenLayersWidget.get_context   s(    	+Ku%%%&*k,&?DK
##&*DK
#
  E  	Zs++ 	$U++!:.   KUTWXXX  	eo++--??*,,E &*%5%5%7%7M"
 #F {6*223<< . =H 	% ;v&DzT!!	)CMM$''''CC$   LLV
D#   CCCCCC i "%DK;'''{s0   A/ /B( B##B(#E/ /
F'9$F""F'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                            |d          r|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   s5   	8 	8 	8	A 	A 	A
 4Bw,&?: /37 /37 .#6	 09 	- 	-,J{z511 -&(()M$+j*ABBEE H,,%Idk*&=>>EE UCL00 K
3EE SF**"T[%<<EE#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      s     1 1 1 1 1 1 ? ? ? ? ? ? ? ? ) ) ) ) ) ) $ $ $ $ $ $  = = ? ?@		/	0	0g g g g gx g g g g gr0   