B
    @\	                 @   sn   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m  mZ ddlmZmZ dZdd Ze ZdS )	a)   This modules exposes geometry data for Unites States. It exposes a
dictionary ``data``, which is indexed by the two-tuples:

.. code-block:: python

    (state_id, county_id)

that have the following dictionaries as the associated value:

.. code-block:: python

    data[(1,1)]['name']
    data[(1,1)]['state']
    data[(1,1)]['detailed name']
    data[(1,1)]['lats']
    data[(1,1)]['lons']

Entries for ``'name'`` can have duplicates for certain states (e.g. Virginia).
The combination of ``'detailed name'`` and ``'state'`` will always be unique.

    )absolute_importdivisionprint_functionunicode_literalsN   )external_pathopen_csv)datac              C   s   t d} i }t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|t|
t|f< q@W W dQ R X |S )z

    ZNaNzUS_Counties.csv,")Z	delimiterZ	quotecharz).//outerBoundaryIs/LinearRing/coordinatesr   c             s   s    | ]}| d dd V  qdS )r
   Nr   )split).0c r   ;lib/python3.7/site-packages/bokeh/sampledata/us_counties.py	<genexpr>Y   s    z_read_data.<locals>.<genexpr>c             S   s    g | ]\}}t |t |fqS r   )float)r   lonlatr   r   r   
<listcomp>Z   s    z_read_data.<locals>.<listcomp>)namezdetailed namestatelatslonsN)r   r   r   nextcsvreaderstretZ
fromstring	enumeratefindallappendtextr   listzipextendint)nanr	   fr   rowr   Zdummyr   ZgeometryZdet_nameZstate_idZ	county_idZxmlr   r   iZpolyZcoordsr   r   r   r   r   
_read_dataE   s2    





&r+   )__doc__Z
__future__r   r   r   r   ZloggingZ	getLogger__name__logr   Zxml.etree.cElementTreeZetreeZcElementTreer   Zutil.sampledatar   r   __all__r+   r	   r   r   r   r   <module>   s   
'