3
(hd                 @   s0   d Z ddlZddlmZ ddlmZ dd ZdS )z+
 Utilities for manipulating Geometry WKT.
    N)six)RemovedInDjango20Warningc                s   t jdtdd t|tr$d| }nt|tjr6|}ntdj||g  fddfdd	fd
ddjdd | D S )a3  
    Returns WKT text of the geometry according to the given precision (an
    integer or a string).  If the precision is an integer, then the decimal
    places of coordinates WKT will be truncated to that number:

     >>> from django.contrib.gis.geos import Point
     >>> pnt = Point(5, 23)
     >>> pnt.wkt
     'POINT (5.0000000000000000 23.0000000000000000)'
     >>> precision_wkt(pnt, 1)
     'POINT (5.0 23.0)'

    If the precision is a string, it must be valid Python format string
    (e.g., '%20.7f') -- thus, you should know what you're doing.
    z>precision_wkt() is deprecated in favor of the WKTWriter class.   )
stacklevelz%%.%df c                s   dj  fdd| D S )N,c             3   s   | ]} |d d  V  qd S )Nr    ).0c)	coord_fmtr   @/tmp/pip-install-q3hcpn_q/Django/django/contrib/gis/utils/wkt.py	<genexpr>*   s    z:precision_wkt.<locals>.formatted_coords.<locals>.<genexpr>)join)coords)r   r   r   formatted_coords)   s    z'precision_wkt.<locals>.formatted_coordsc                s   dj  fdd| D S )Nr   c             3   s   | ]}d  | V  qdS )z(%s)Nr   )r	   r)r   r   r   r   -   s    z8precision_wkt.<locals>.formatted_poly.<locals>.<genexpr>)r   )poly)r   r   r   formatted_poly,   s    z%precision_wkt.<locals>.formatted_polyc             3   s   t | jj }d| V  |dkr0 | jfV  n|dkrF | jV  nv|dkrZ| V  nb|dkrp | jV  nL|dkrd	jfd
d| D V  n(|dkrd	jfdd| D V  ntdV  d S )Nz%s(ZPOINT
LINESTRING
LINEARRINGPOLYGONMULTILINESTRINGZ
MULTIPOINTZMULTIPOLYGONr   c             3   s   | ]}d  | V  qdS )z(%s)Nr   )r	   p)r   r   r   r   ;   s    z8precision_wkt.<locals>.formatted_geom.<locals>.<genexpr>ZGEOMETRYCOLLECTIONc             3   s&   | ]}d j dd  |D V  qdS ) c             s   s   | ]
}|V  qd S )Nr   )r	   wktr   r   r   r   =   s    zBprecision_wkt.<locals>.formatted_geom.<locals>.<genexpr>.<genexpr>N)r   )r	   child)formatted_geomr   r   r   =   s    ))r   r   )r   r   )strZ	geom_typeupperr   r   	TypeError)gZgtype)r   r   r   r   r   r   /   s     
z%precision_wkt.<locals>.formatted_geomr   c             s   s   | ]
}|V  qd S )Nr   )r	   r   r   r   r   r   B   s    z precision_wkt.<locals>.<genexpr>)	warningswarnr   
isinstanceintr   string_typesr    r   )ZgeomprecZnum_fmtr   )r   r   r   r   r   precision_wkt
   s    


r(   )__doc__r"   Zdjango.utilsr   Zdjango.utils.deprecationr   r(   r   r   r   r   <module>   s   