o
    Ò­Òc.  ã                   @   sb   d Z ddlmZ h d£Zh d£ZG dd„ dƒZG dd„ deƒZG d	d
„ d
eƒZ			ddd„ZdS )z0Performs requests to the Google Maps Static API.é    )Úconvert>   ZjpgZpng8ZpngZpng32zjpg-baselineZgif>   ZterrainZhybridZ	satelliteZroadmapc                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚStaticMapParamz4Base class to handle parameters for Maps Static API.c                 C   s
   g | _ d S ©N)Úparams©Úself© r   úX/Users/abhinavbhinder/Documents/map/venv/lib/python3.10/site-packages/googlemaps/maps.pyÚ__init__   s   
zStaticMapParam.__init__c                 C   s   t  d| j¡S )zvConverts a list of parameters to the format expected by
        the Google Maps server.

        :rtype: str

        ú|)r   Z	join_listr   r   r   r   r	   Ú__str__!   s   zStaticMapParam.__str__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r
   r   r   r   r   r	   r      s    r   c                       s$   e Zd ZdZ	d‡ fdd„	Z‡  ZS )ÚStaticMapMarkerz.Handles marker parameters for Maps Static API.Nc                    sŒ   t t| ƒ ¡  |r| j d| ¡ |r| j d| ¡ |r;t|ƒdks/| ¡ r+| ¡ r/| ¡ s3t	dƒ‚| j d| ¡ | j t
 |¡¡ dS )a¬  
        :param locations: Specifies the locations of the markers on
            the map.
        :type locations: list

        :param size: Specifies the size of the marker.
        :type size: str

        :param color: Specifies a color of the marker.
        :type color: str

        :param label: Specifies a single uppercase alphanumeric
            character to be displaied on marker.
        :type label: str
        zsize:%súcolor:%sé   z0Marker label must be alphanumeric and uppercase.zlabel:%sN)Úsuperr   r
   r   ÚappendÚlenÚisalphaÚisupperÚisalnumÚ
ValueErrorr   Úlocation_list)r   Z	locationsÚsizeÚcolorÚlabel©Ú	__class__r   r	   r
   .   s   $zStaticMapMarker.__init__)NNN©r   r   r   r   r
   Ú__classcell__r   r   r   r	   r   +   s    ÿr   c                       s&   e Zd ZdZ		d‡ fdd„	Z‡  ZS )ÚStaticMapPathz,Handles path parameters for Maps Static API.Nc                    st   t t| ƒ ¡  |r| j d| ¡ |r| j d| ¡ |r%| j d| ¡ |r/| j d| ¡ | j t |¡¡ dS )aÀ  
        :param points: Specifies the point through which the path
            will be built.
        :type points: list

        :param weight: Specifies the thickness of the path in pixels.
        :type weight: int

        :param color: Specifies a color of the path.
        :type color: str

        :param fillcolor: Indicates both that the path marks off a
            polygonal area and specifies the fill color to use as an
            overlay within that area.
        :type fillcolor: str

        :param geodesic: Indicates that the requested path should be
            interpreted as a geodesic line that follows the curvature
            of the earth.
        :type geodesic: bool
        z	weight:%sr   zfillcolor:%szgeodesic:%sN)r   r#   r
   r   r   r   r   )r   ZpointsÚweightr   Z	fillcolorZgeodesicr   r   r	   r
   S   s   zStaticMapPath.__init__)NNNNr!   r   r   r   r	   r#   P   s
    þr#   Nc                 C   s  dt  |¡i}|	s|s|dustdƒ‚|rt  |¡|d< |dur$||d< |dur,||d< |r:|tvr6tdƒ‚||d< |rH|tvrDtd	ƒ‚||d
< |rN||d< |rT||d< |	rZ|	|d< |
r`|
|d< |rit  |¡|d< |rrt  |¡|d< | jd|dd„ ddid�}| 	¡ S )aÿ  
    Downloads a map image from the Maps Static API.

    See https://developers.google.com/maps/documentation/maps-static/intro
    for more info, including more detail for each parameter below.

    :param size: Defines the rectangular dimensions of the map image.
    :type param: int or list

    :param center: Defines the center of the map, equidistant from all edges
        of the map.
    :type center: dict or list or string

    :param zoom: Defines the zoom level of the map, which determines the
        magnification level of the map.
    :type zoom: int

    :param scale: Affects the number of pixels that are returned.
    :type scale: int

    :param format: Defines the format of the resulting image.
    :type format: string

    :param maptype: defines the type of map to construct. There are several
        possible maptype values, including roadmap, satellite, hybrid,
        and terrain.
    :type maptype: string

    :param language: defines the language to use for display of labels on
        map tiles.
    :type language: string

    :param region: defines the appropriate borders to display, based on
        geo-political sensitivities.
    :type region: string

    :param markers: define one or more markers to attach to the image at
        specified locations.
    :type markers: StaticMapMarker

    :param path: defines a single path of two or more connected points to
        overlay on the image at specified locations.
    :type path: StaticMapPath

    :param visible: specifies one or more locations that should remain visible
        on the map, though no markers or other indicators will be displayed.
    :type visible: list of dict

    :param style: defines a custom style to alter the presentation of
        a specific feature (roads, parks, and other features) of the map.
    :type style: list of dict

    :rtype: iterator containing the raw image data, which typically can be
        used to save an image file locally. For example:

        ```
        f = open(local_filename, 'wb')
        for chunk in client.static_map(size=(400, 400),
                                       center=(52.520103, 13.404871),
                                       zoom=15):
            if chunk:
                f.write(chunk)
        f.close()
        ```
    r   Nz=both center and zoom are requiredwhen markers is not specifedÚcenterÚzoomÚscalezInvalid image formatÚformatzInvalid maptypeÚmaptypeÚlanguageÚregionÚmarkersÚpathÚvisibleÚstylez/maps/api/staticmapc                 S   s   | S r   r   )Úresponser   r   r	   Ú<lambda>ô   s    zstatic_map.<locals>.<lambda>ÚstreamT)Zextract_bodyZrequests_kwargs)
r   r   r   ZlatlngÚMAPS_IMAGE_FORMATSÚMAPS_MAP_TYPESr   Ú
componentsZ_requestZiter_content)Zclientr   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r   r0   r   r   r	   Ú
static_map}   sN   Fÿür6   )NNNNNNNNNNN)	r   Ú
googlemapsr   r3   r4   r   r   r#   r6   r   r   r   r	   Ú<module>   s   %.ý