B
    @\                 @   sz   d Z ddlmZmZmZmZ ddlZeeZ	ddl
Z
ddlZddlZddlm  mZ ddlmZ dZdd Ze ZdS )	a1  
This modules exposes geometry data for Unites States. It exposes a dictionary 'data' which is
indexed by the two letter state code (e.g., 'CA', 'TX') and has the following dictionary as the
associated value:

    data['CA']['name']
    data['CA']['region']
    data['CA']['lats']
    data['CA']['lons']

    )absolute_importdivisionprint_functionunicode_literalsN   )package_path)datac           	   C   s  t d} i }ttd}t|d}t| tj|t	dt	dd}x|D ]}|\}}}}	}
t
|	}g }g }xxt|dD ]f\}}|dkr||  ||  d	d
 |j D }ttdd |D  \}}|| || qW ||||d||< qNW W dQ R X |S )z

    ZNaNz"US_Regions_State_Boundaries.csv.gzzutf-8,")Z	delimiterZ	quotecharz).//outerBoundaryIs/LinearRing/coordinatesr   c             s   s    | ]}| d dd V  qdS )r	   Nr   )split).0c r   9lib/python3.7/site-packages/bokeh/sampledata/us_states.py	<genexpr>S   s    z_read_data.<locals>.<genexpr>c             S   s    g | ]\}}t |t |fqS r   )float)r   lonlatr   r   r   
<listcomp>T   s    z_read_data.<locals>.<listcomp>)nameregionlatslonsN)r   gzipopenr   codecs
iterdecodenextcsvreaderstretZ
fromstring	enumeratefindallappendtextr   listzipextend)nanr   fZdecodedr   rowr   r   codeZgeometryZdummyZxmlr   r   iZpolyZcoordsr   r   r   r   r   
_read_data>   s2    





r.   )__doc__Z
__future__r   r   r   r   ZloggingZ	getLogger__name__logr   r   r   Zxml.etree.cElementTreeZetreeZcElementTreer!   Zutil.sampledatar   __all__r.   r   r   r   r   r   <module>   s   
'