Ejemplo n.º 1
0
def g_directed_hausdorff(t1, t2):
    """
    Usage
    -----
    directed hausdorff distance from trajectory t1 to trajectory t2.

    Parameters
    ----------
    param t1 :  len(t1)x2 numpy_array
    param t2 :  len(t2)x2 numpy_array

    Returns
    -------
    dh : float, directed hausdorff from trajectory t1 to trajectory t2
    """
    n0 = len(t1)
    n1 = len(t2)
    dh = 0
    for j in range(n1):
        dist_j0 = 9e100
        for i in range(n0 - 1):
            dist_j0 = min(
                dist_j0,
                point_to_path(t1[i][0], t1[i][1], t1[i + 1][0], t1[i + 1][1],
                              t2[j][0], t2[j][1]))
        dh = max(dh, dist_j0)
    return dh
Ejemplo n.º 2
0
def g_spd(t1, t2):
    """
    Usage
    -----
    The spd-distance of trajectory t2 from trajectory t1
    The spd-distance is the sum of the all the point-to-path distance of points of t1 from trajectory t2

    Parameters
    ----------
    param t1 :  len(t1)x2 numpy_array
    param t2 :  len(t2)x2 numpy_array

    Returns
    -------
    spd : float
           spd-distance of trajectory t2 from trajectory t1
    """
    n0 = len(t1)
    n1 = len(t2)
    lats0 = t1[:, 1]
    lons0 = t1[:, 0]
    lats1 = t2[:, 1]
    lons1 = t2[:, 0]
    dist = 0
    for j in range(n1):
        dist_j0 = 9e100
        for i in range(n0 - 1):
            dist_j0 = np.min((dist_j0, point_to_path(lons0[i], lats0[i], lons0[i + 1], lats0[i + 1], lons1[j],
                                                     lats1[j])))
        dist = dist + dist_j0
    dist = float(dist) / n1
    return dist
Ejemplo n.º 3
0
def g_directed_hausdorff (t1, t2):
    """
    Usage
    -----
    directed hausdorff distance from trajectory t1 to trajectory t2.

    Parameters
    ----------
    param t1 :  len(t1)x2 numpy_array
    param t2 :  len(t2)x2 numpy_array

    Returns
    -------
    dh : float, directed hausdorff from trajectory t1 to trajectory t2
    """
    n0=len(t1)
    n1=len(t2)
    dh=0
    for j in range(n1) :
        dist_j0=9e100
        for i in range(n0-1):
            dist_j0=min(dist_j0,point_to_path(t1[i][0],t1[i][1],t1[i+1][0],t1[i+1][1],t2[j][0],t2[j][1]))
        dh=max(dh,dist_j0)
    return dh