import requests


def near(x, y, url, resource='/grid/near'):
    """Determines chips and tiles that lie a point

    Args:
        x (int): projection coordinate x
        y (int): projection coordinate y
        url (str): protocol://host:port/path
        resource (str): /grid/near/resource (default: /grid/near)
    
    Returns:
        dict

    Example:
        >>> chipmunk.near(x=0, y=0, url='http://host:port/path')
        {'chip': [{'grid-pt': [854.0, 1105.0], 'proj-pt': [-3585.0, -195.0]},
                  {'grid-pt': [854.0, 1104.0], 'proj-pt': [-3585.0, 2805.0]},
                  {'grid-pt': [854.0, 1103.0], 'proj-pt': [-3585.0, 5805.0]},
                  {'grid-pt': [855.0, 1105.0], 'proj-pt': [-585.0, -195.0]},
                  {'grid-pt': [855.0, 1104.0], 'proj-pt': [-585.0, 2805.0]},
                  {'grid-pt': [855.0, 1103.0], 'proj-pt': [-585.0, 5805.0]},
                  {'grid-pt': [856.0, 1105.0], 'proj-pt': [2415.0, -195.0]},
                  {'grid-pt': [856.0, 1104.0], 'proj-pt': [2415.0, 2805.0]},
                  {'grid-pt': [856.0, 1103.0], 'proj-pt': [2415.0, 5805.0]}],
         'tile': [{'grid-pt': [16.0, 23.0], 'proj-pt': [-165585.0, -135195.0]},
                  {'grid-pt': [16.0, 22.0], 'proj-pt': [-165585.0, 14805.0]},
                  {'grid-pt': [16.0, 21.0], 'proj-pt': [-165585.0, 164805.0]},
                  {'grid-pt': [17.0, 23.0], 'proj-pt': [-15585.0, -135195.0]},
                  {'grid-pt': [17.0, 22.0], 'proj-pt': [-15585.0, 14805.0]},
                  {'grid-pt': [17.0, 21.0], 'proj-pt': [-15585.0, 164805.0]},
                  {'grid-pt': [18.0, 23.0], 'proj-pt': [134415.0, -135195.0]},
                  {'grid-pt': [18.0, 22.0], 'proj-pt': [134415.0, 14805.0]},
                  {'grid-pt': [18.0, 21.0], 'proj-pt': [134415.0, 164805.0]}]}
    """
    
    url = '{}{}'.format(url, resource)
    return requests.get(url=url, params={'x': x, 'y': y}).json()