B
    ¥0H[Ò  ã               @   sd   d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 dZ
G dd„ deƒZG d	d
„ d
eƒZdS )é    )Ú
ModelAdmin)ÚOpenLayersWidget)Úmodels)ÚOGRGeomType)ÚMediai  c                   s´   e Zd ZdZdZdZdZdZdZg Z	dZ
dZdZdZdZdZdZdZdZdZdZdZdZd	Zd
ZdZe
d ZdZdZdZddiZdZe Z!e"‡ fdd„ƒZ#‡ fdd„Z$dd„ Z%‡  Z&S )ÚGeoModelAdminz�
    The administration options class for Geographic models. Map settings
    may be overloaded from their defaults to create custom maps.
    r   é   Fé   TiX  i�  iæ  zgis/admin/openlayers.htmlzFhttps://cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/OpenLayers.jsé   z&http://vmap0.tiles.osgeo.org/wms/vmap0ÚbasiczOpenLayers WMSÚformatz
image/jpegc                s   t ƒ jt| jg| j d� S )z-Injects OpenLayers JavaScript into the admin.)Zjs)ÚsuperÚmediar   Úopenlayers_urlÚextra_js)Úself)Ú	__class__© údC:\Users\HIRONO~1\AppData\Local\Temp\pip-install-6bm3nxem\django\django\contrib\gis\admin\options.pyr   /   s    zGeoModelAdmin.mediac                sF   t |tjƒr0|jdk r0|  |¡|d< |jf |ŽS tƒ j||f|ŽS dS )z²
        Overloaded from ModelAdmin so that an OpenLayersWidget is used
        for viewing/editing 2D GeometryFields (OpenLayers 2 does not support
        3D editing).
        é   ÚwidgetN)Ú
isinstancer   ZGeometryFieldZdimÚget_map_widgetZ	formfieldr   Úformfield_for_dbfield)r   Údb_fieldÚrequestÚkwargs)r   r   r   r   4   s    z#GeoModelAdmin.formfield_for_dbfieldc                sV   ˆj dk‰ˆr2ˆj dkrd‰ q6tˆj  dd¡ƒ‰ nd‰ G ‡ ‡‡‡fdd„dˆjƒ}|S )	z»
        Return a subclass of the OpenLayersWidget (or whatever was specified
        in the `widget` attribute) using the settings from the attributes set
        in this class.
        )Ú
MULTIPOINTÚMULTILINESTRINGÚMULTIPOLYGONÚGEOMETRYCOLLECTIONr    ZAnyZMULTIÚ ÚNonec            "       sâ   e Zd Z”jZ”jZdZ”jr@dd„ ”j ¡ D ƒZdd e¡ Z”j	”j
”j”jpV”je”jƒ”j””j”j” ”jdk”jdk”jdk”jd	k”j”j”j”j”j”j”j”j”j”j”j”j”j”j”j ”j!”j"e”jd
œ!Z#dS )z+GeoModelAdmin.get_map_widget.<locals>.OLMapr!   c             S   s   g | ]}d | ‘qS )z%s: '%s'r   )Ú.0Úpairr   r   r   ú
<listcomp>V   s    z6GeoModelAdmin.get_map_widget.<locals>.OLMap.<listcomp>z, %sz, ZGEOMETRY)Z
LINESTRINGr   )ZPOLYGONr   )ÚPOINTr   )!Údefault_lonÚdefault_latÚdefault_zoomÚdisplay_wktÚ	geom_typeÚ
field_nameÚis_collectionÚ
scrollableÚlayerswitcherÚcollection_typeZ
is_genericZis_linestringZ
is_polygonZis_pointÚnum_zoomÚmax_zoomÚmin_zoomÚunitsÚmax_resolutionÚ
max_extentÚ
modifiableÚmouse_positionÚ
scale_textÚ	map_widthÚ
map_heightÚ
point_zoomZsridÚdisplay_sridÚwms_urlÚ	wms_layerÚwms_nameÚwms_optionsÚdebugN)$Ú__name__Ú
__module__Ú__qualname__Úmap_templateZtemplate_namer+   rA   ÚitemsÚjoinr'   r(   r)   rB   r*   r   Únamer.   r/   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   Úmap_sridr=   r>   r?   r@   Úparamsr   )r0   r   r-   r   r   r   ÚOLMapP   sN   
rL   )r+   r   Úreplacer   )r   r   rL   r   )r0   r   r-   r   r   r   A   s    

+zGeoModelAdmin.get_map_widget)'rC   rD   rE   Ú__doc__r'   r(   r)   r*   r=   r   r1   r2   r3   r4   r5   r6   r7   r8   r9   r/   r.   r:   r;   rJ   rF   r   r<   r>   r?   r@   rA   rB   r   r   Úpropertyr   r   r   Ú__classcell__r   r   )r   r   r   
   sB   r   c               @   s,   e Zd ZdZdZeZdZdZed Z	dZ
dS )ÚOSMGeoAdminzgis/admin/osm.htmlé   z%-20037508,-20037508,20037508,20037508z156543.0339r
   ÚmN)rC   rD   rE   rF   r1   Úspherical_mercator_sridrJ   r6   r5   r<   r4   r   r   r   r   rQ   ~   s   rQ   N)Zdjango.contrib.adminr   Z django.contrib.gis.admin.widgetsr   Zdjango.contrib.gis.dbr   Zdjango.contrib.gis.gdalr   Zdjango.formsr   rT   r   rQ   r   r   r   r   Ú<module>   s   t