def request_url(lat, lon, maxpoints=0):
    """
    Convert lat and lon to a url query string.

    Converts lat and lon to a query string using osrm router.

    Parameters
    ----------
    lat : list
        ordered list of all latitudes
    lon : list
        ordered list of all longitudes
    maxpoints: int
        maximum number of points to be included, defaults to all

    Returns
    -------
    url : string
        query url to be used for osrm routing
    """
    # set maxpoints to len lat if added
    if maxpoints == 0:
        maxpoints = len(lat)

    # how many points should we include? can we include all of them?
    baseurl = 'http://router.project-osrm.org/match/v1/walking/'
    options = '?overview=full&annotations=true'

    coords = ''
    # pick every nth coordinate up to maxpoints
    npoints = len(lat) % maxpoints
    point_interval = int(len(lat) / max(npoints, 1))
    for i in range(npoints):
        coords += str(lon[i * point_interval]) + ',' + str(lat[i * point_interval]) + ';'

    return baseurl + coords[:-1] + options