{"id":1561,"date":"2024-01-04T19:41:32","date_gmt":"2024-01-04T11:41:32","guid":{"rendered":"https:\/\/www.yeetrack.com\/?p=1561"},"modified":"2024-01-04T19:46:01","modified_gmt":"2024-01-04T11:46:01","slug":"%e8%b1%aa%e6%96%af%e5%a4%9a%e5%a4%ab%e8%b7%9d%e7%a6%bb%ef%bc%88hausdorff-distance%ef%bc%89%e8%ae%a1%e7%ae%97%e8%bd%a8%e8%bf%b9%e7%9b%b8%e4%bc%bc%e5%ba%a6","status":"publish","type":"post","link":"https:\/\/www.yeetrack.com\/?p=1561","title":{"rendered":"\u8c6a\u65af\u591a\u592b\u8ddd\u79bb\uff08Hausdorff Distance\uff09\u8ba1\u7b97\u8f68\u8ff9\u76f8\u4f3c\u5ea6"},"content":{"rendered":"<p>\u6700\u8fd1\u9879\u76ee\u9700\u6c42\uff0c\u8981\u5bf9\u8fd0\u8425\u8f66\u8f86\u7684\u8fd0\u8425\u62a5\u8868\uff0c\u6709\u4e2a\u9700\u6c42\u662f\u6309\u7167\u8fd0\u8425\u7ebf\u8def\u7684\u7ef4\u5ea6\u8fdb\u884c\u7edf\u8ba1\uff0c\u9700\u8981\u5c06\u6240\u6709\u8f66\u8f86\u7684\u8fd0\u8425\u8f68\u8ff9\u8fdb\u884c\u7ebf\u8def\u7684\u5339\u914d\u3002\u5e73\u53f0\u4e2d\u5df2\u7ecf\u7ef4\u62a4\u4e86\u6240\u6709\u7684\u8fd0\u8425\u7ebf\u8def\uff0c\u6240\u4ee5\u53ea\u9700\u8981\u5c06\u8f66\u8f86\u8f68\u8ff9\u4e0e\u8fd0\u8425\u7ebf\u8def\u8fdb\u884c\u76f8\u4f3c\u5ea6\u8ba1\u7b97\u5c31\u53ef\u4ee5\u4e86\u3002  <\/p>\n<p><!--more--><\/p>\n<p>\u5224\u65ad\u4e24\u6761\u8f68\u8ff9\u7684\u76f8\u4f3c\u6027\u65b9\u6cd5\u6709\u5f88\u591a:  <\/p>\n<ul>\n<li>\u57fa\u4e8e\u70b9\u65b9\u6cd5\uff1a EDR\uff0cLCSS\uff0cDTW\u7b49<\/li>\n<li>\u57fa\u4e8e\u5f62\u72b6\u7684\u65b9\u6cd5\uff1a Frechet\uff0c Hausdorff<\/li>\n<li>\u57fa\u4e8e\u5206\u6bb5\u7684\u65b9\u6cd5\uff1aOne Way Distance, LIP distance<\/li>\n<li>\u57fa\u4e8e\u7279\u5b9a\u4efb\u52a1\u7684\u65b9\u6cd5\uff1aTRACLUS\uff0c Road Network\uff0cgrid\u7b49<br \/>\n\u6458\u81ea <a href=\"https:\/\/www.zhihu.com\/question\/27213170\">\u5982\u4f55\u5224\u65ad\u4e24\u6761\u8f68\u8ff9\uff08\u6216\u66f2\u7ebf\uff09\u7684\u76f8\u4f3c\u5ea6\uff1f<\/a>  <\/li>\n<\/ul>\n<p>\u8fd9\u91cc\u7528Hausdorff Distance\u6765\u5b9e\u73b0\u3002 <\/p>\n<h3>\u4ec0\u4e48\u662f\u8c6a\u65af\u591a\u592b\u8ddd\u79bb<\/h3>\n<p>Hausdorff\u8ddd\u79bb\u662f\u63cf\u8ff0\u4e24\u7ec4\u70b9\u96c6\u4e4b\u95f4\u76f8\u4f3c\u7a0b\u5ea6\u7684\u4e00\u79cd\u91cf\u5ea6\uff0c\u5b83\u662f\u4e24\u4e2a\u70b9\u96c6\u4e4b\u95f4\u8ddd\u79bb\u7684\u4e00\u79cd\u5b9a\u4e49\u5f62\u5f0f\u3002<a href=\"https:\/\/www.cnblogs.com\/icmzn\/p\/8531719.html\">https:\/\/www.cnblogs.com\/icmzn\/p\/8531719.html<\/a><\/p>\n<h3>\u8c6a\u65af\u591a\u592b\u8ddd\u79bb\u4f7f\u7528\u573a\u666f<\/h3>\n<p>\u6839\u636e\u8d44\u6599\uff0cHausdorff Distance\u8f83\u591a\u7528\u4e8e\u7269\u4f53\u8f6e\u5ed3\u7684\u76f8\u4f3c\u5ea6\u5224\u65ad\uff0c\u5728\u8ba1\u7b97\u673a\u56fe\u50cf\u8bc6\u522b\u9886\u57df\u5e94\u7528\u8f83\u591a\uff0c\u5982\u533b\u7597\u9886\u57df\u80bf\u7624\u8bc6\u522b\u3001\u519b\u4e8b\u9886\u57df\u6253\u51fb\u7269\u5224\u65ad\u7b49\u3002 <\/p>\n<p>\u5177\u4f53\u4ee3\u7801(java + geotools)\uff1a<br \/>\nGeoTools\u4e2d\u63d0\u4f9b\u7684<code>HausdorffSimilarityMeasure.measure()<\/code>\u65b9\u6cd5\uff0c\u8fd4\u56de\u7684\u662f\u4e24\u6761\u7ebf\u8def\u7684\u76f8\u4f3c\u5ea6\uff0c\u8fd4\u56de\u503c0-1\uff0c1\u8868\u793a\u5b8c\u5168\u4e00\u81f4\u3002  <\/p>\n<p>POM\u4ed3\u5e93\uff1a<\/p>\n<pre><code class=\"language-xml\">&lt;repositories&gt;\n    &lt;repository&gt;\n      &lt;id&gt;osgeo&lt;\/id&gt;\n      &lt;name&gt;OSGeo Release Repository&lt;\/name&gt;\n      &lt;url&gt;https:\/\/repo.osgeo.org\/repository\/release\/&lt;\/url&gt;\n      &lt;snapshots&gt;&lt;enabled&gt;true&lt;\/enabled&gt;&lt;\/snapshots&gt;\n      &lt;releases&gt;&lt;enabled&gt;true&lt;\/enabled&gt;&lt;\/releases&gt;\n    &lt;\/repository&gt;\n  &lt;\/repositories&gt;<\/code><\/pre>\n<p>GeoTools\u4f9d\u8d56\uff1a<\/p>\n<pre><code class=\"language-xml\">   &lt;dependency&gt;\n      &lt;groupId&gt;org.geotools&lt;\/groupId&gt;\n      &lt;artifactId&gt;gt-main&lt;\/artifactId&gt;\n      &lt;version&gt;25.0&lt;\/version&gt;\n    &lt;\/dependency&gt;<\/code><\/pre>\n<p>\u6d4b\u8bd5\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-java\">package com.yeetrack;\n\nimport com.alibaba.fastjson.JSONArray;\nimport com.alibaba.fastjson.JSONObject;\nimport lombok.extern.slf4j.Slf4j;\nimport org.geotools.geometry.jts.JTSFactoryFinder;\nimport org.geotools.referencing.GeodeticCalculator;\nimport org.geotools.referencing.crs.DefaultGeographicCRS;\nimport org.junit.Test;\nimport org.locationtech.jts.algorithm.match.HausdorffSimilarityMeasure;\nimport org.locationtech.jts.geom.*;\n\n\/**\n * \u6587\u6863\uff1ahttps:\/\/shengshifeiyang.gitee.io\/geotools-learning\/\n *\/\n@Slf4j\npublic class GisUtil {\n\n    \/**\n     * pi\n     *\/\n    public final static double pi = 3.1415926535897932384626;\n    \/**\n     * a\n     *\/\n    public final static double a = 6378245.0;\n    \/**\n     * ee\n     *\/\n    public final static double ee = 0.00669342162296594323;\n\n    \/**\n     * @Description WGS84 to \u706b\u661f\u5750\u6807\u7cfb (GCJ-02)\n     * @param lon \u7ecf\u5ea6\n     * @param lat \u7eac\u5ea6\n     * @return\n     *\/\n    public static double[] wgs84_To_Gcj02(double lon, double lat) {\n        if (outOfChina(lat, lon)) {\n            return null;\n        }\n        double dLat = transformLat(lon - 105.0, lat - 35.0);\n        double dLon = transformLon(lon - 105.0, lat - 35.0);\n        double radLat = lat \/ 180.0 * pi;\n        double magic = Math.sin(radLat);\n        magic = 1 - ee * magic * magic;\n        double sqrtMagic = Math.sqrt(magic);\n        dLat = (dLat * 180.0) \/ ((a * (1 - ee)) \/ (magic * sqrtMagic) * pi);\n        dLon = (dLon * 180.0) \/ (a \/ sqrtMagic * Math.cos(radLat) * pi);\n        double mgLat = lat + dLat;\n        double mgLon = lon + dLon;\n        return new double[] { mgLon, mgLat };\n    }\n\n    \/**\n     * @Description \u706b\u661f\u5750\u6807\u7cfb (GCJ-02) to WGS84\n     * @param lon\n     * @param lat\n     * @return\n     *\/\n    public static double[] gcj02_To_Wgs84(double lon, double lat) {\n        double[] gps = transform(lat, lon);\n        double lontitude = lon * 2 - gps[1];\n        double latitude = lat * 2 - gps[0];\n        return new double[] { lontitude, latitude };\n    }\n\n    \/**\n     * @Description \u706b\u661f\u5750\u6807\u7cfb (GCJ-02) to \u767e\u5ea6\u5750\u6807\u7cfb (BD-09)\n     * @param gg_lon\n     * @param gg_lat\n     * @return\n     *\/\n    public static double[] gcj02_To_Bd09(double gg_lon, double gg_lat) {\n        double x = gg_lon, y = gg_lat;\n        double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * pi);\n        double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * pi);\n        double bd_lon = z * Math.cos(theta) + 0.0065;\n        double bd_lat = z * Math.sin(theta) + 0.006;\n        return new double[] { bd_lon, bd_lat };\n    }\n\n    \/**\n     * @Description \u767e\u5ea6\u5750\u6807\u7cfb (BD-09) to \u706b\u661f\u5750\u6807\u7cfb (GCJ-02)\n     * @param bd_lon\n     * @param bd_lat\n     * @return\n     *\/\n    public static double[] bd09_To_Gcj02(double bd_lon, double bd_lat) {\n        double x = bd_lon - 0.0065, y = bd_lat - 0.006;\n        double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * pi);\n        double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * pi);\n        double gg_lon = z * Math.cos(theta);\n        double gg_lat = z * Math.sin(theta);\n        return new double[] { gg_lon, gg_lat };\n    }\n    \/**\n     * @Description \u767e\u5ea6\u5750\u6807\u7cfb (BD-09) to WGS84\n     * @param bd_lat\n     * @param bd_lon\n     * @return\n     *\/\n    public static double[] bd09_To_Wgs84(double bd_lon,double bd_lat) {\n        double[] gcj02 = GisUtil.bd09_To_Gcj02(bd_lon, bd_lat);\n        double[] map84 = GisUtil.gcj02_To_Wgs84(gcj02[0], gcj02[1]);\n        return map84;\n\n    }\n\n    \/**\n     * @Description \u5224\u65ad\u662f\u5426\u5728\u4e2d\u56fd\u8303\u56f4\u5185\n     * @param lat\n     * @param lon\n     * @return\n     *\/\n    public static boolean outOfChina(double lat, double lon) {\n        if (lon &lt; 72.004 || lon &gt; 137.8347)\n            return true;\n        if (lat &lt; 0.8293 || lat &gt; 55.8271)\n            return true;\n        return false;\n    }\n\n    \/**\n     * @Description transform\n     * @param lat\n     * @param lon\n     * @return\n     *\/\n    private static double[] transform(double lat, double lon) {\n        if (outOfChina(lat, lon)) {\n            return new double[] { lat, lon };\n        }\n        double dLat = transformLat(lon - 105.0, lat - 35.0);\n        double dLon = transformLon(lon - 105.0, lat - 35.0);\n        double radLat = lat \/ 180.0 * pi;\n        double magic = Math.sin(radLat);\n        magic = 1 - ee * magic * magic;\n        double sqrtMagic = Math.sqrt(magic);\n        dLat = (dLat * 180.0) \/ ((a * (1 - ee)) \/ (magic * sqrtMagic) * pi);\n        dLon = (dLon * 180.0) \/ (a \/ sqrtMagic * Math.cos(radLat) * pi);\n        double mgLat = lat + dLat;\n        double mgLon = lon + dLon;\n        return new double[] { mgLat, mgLon };\n    }\n\n    \/**\n     * @Description transformLat\n     * @param x\n     * @param y\n     * @return\n     *\/\n    private static double transformLat(double x, double y) {\n        double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x));\n        ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 \/ 3.0;\n        ret += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y \/ 3.0 * pi)) * 2.0 \/ 3.0;\n        ret += (160.0 * Math.sin(y \/ 12.0 * pi) + 320 * Math.sin(y * pi \/ 30.0)) * 2.0 \/ 3.0;\n        return ret;\n    }\n\n    \/**\n     * @Description transformLon\n     * @param x\n     * @param y\n     * @return\n     *\/\n    public static double transformLon(double x, double y) {\n        double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1* Math.sqrt(Math.abs(x));\n        ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 \/ 3.0;\n        ret += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x \/ 3.0 * pi)) * 2.0 \/ 3.0;\n        ret += (150.0 * Math.sin(x \/ 12.0 * pi) + 300.0 * Math.sin(x \/ 30.0* pi)) * 2.0 \/ 3.0;\n        return ret;\n    }\n\n    \/**\n     * @Description WGS84 to \u9ad8\u65af\u6295\u5f71(6\u5ea6\u5206\u5e26)\n     * @param longitude \u7ecf\u5ea6\n     * @param latitude \u7eac\u5ea6\n     * @return double[] x y\n     *\/\n    public static double[] wgs84_To_Gauss6(double longitude, double latitude) {\n        int ProjNo = 0;\n        int ZoneWide; \/\/ \/\/\u5e26\u5bbd\n        double[] output = new double[2];\n        double longitude1, latitude1, longitude0, X0, Y0, xval, yval;\n        double a, f, e2, ee, NN, T, C, A, M, iPI;\n        iPI = 0.0174532925199433; \/\/ \/\/3.1415926535898\/180.0;\n        ZoneWide = 6; \/\/6\u5ea6\u5e26\u5bbd\n        a = 6378137.0;\n        f = 1.0 \/ 298.257223563; \/\/WGS84\u5750\u6807\u7cfb\u53c2\u6570\n        \/\/a = 6378245.0;f = 1.0 \/ 298.3; \/\/ 54\u5e74\u5317\u4eac\u5750\u6807\u7cfb\u53c2\u6570\n        \/\/ \/\/a=6378140.0; f=1\/298.257; \/\/80\u5e74\u897f\u5b89\u5750\u6807\u7cfb\u53c2\u6570\n        ProjNo = (int) (longitude \/ ZoneWide);\n        longitude0 = (double)(ProjNo * ZoneWide + ZoneWide \/ 2);\n        longitude0 = longitude0 * iPI;\n        longitude1 = longitude * iPI; \/\/ \u7ecf\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6\n        latitude1 = latitude * iPI; \/\/ \u7eac\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6\n        e2 = 2 * f - f * f;\n        ee = e2 \/ (1.0 - e2);\n        NN = a\n                \/ Math.sqrt(1.0 - e2 * Math.sin(latitude1)\n                * Math.sin(latitude1));\n        T = Math.tan(latitude1) * Math.tan(latitude1);\n        C = ee * Math.cos(latitude1) * Math.cos(latitude1);\n        A = (longitude1 - longitude0) * Math.cos(latitude1);\n        M = a\n                * ((1 - e2 \/ 4 - 3 * e2 * e2 \/ 64 - 5 * e2 * e2 * e2 \/ 256)\n                * latitude1\n                - (3 * e2 \/ 8 + 3 * e2 * e2 \/ 32 + 45 * e2 * e2 * e2\n                \/ 1024) * Math.sin(2 * latitude1)\n                + (15 * e2 * e2 \/ 256 + 45 * e2 * e2 * e2 \/ 1024)\n                * Math.sin(4 * latitude1) - (35 * e2 * e2 * e2 \/ 3072)\n                * Math.sin(6 * latitude1));\n        \/\/ \u56e0\u4e3a\u662f\u4ee5\u8d64\u9053\u4e3aY\u8f74\u7684\uff0c\u4e0e\u6211\u4eec\u5357\u5317\u4e3aY\u8f74\u662f\u76f8\u53cd\u7684\uff0c\u6240\u4ee5xy\u4e0e\u9ad8\u65af\u6295\u5f71\u7684\u6807\u51c6xy\u6b63\u597d\u76f8\u53cd;\n        xval = NN\n                * (A + (1 - T + C) * A * A * A \/ 6 + (5 - 18 * T + T * T + 14\n                * C - 58 * ee)\n                * A * A * A * A * A \/ 120);\n        yval = M\n                + NN\n                * Math.tan(latitude1)\n                * (A * A \/ 2 + (5 - T + 9 * C + 4 * C * C) * A * A * A * A \/ 24 + (61\n                - 58 * T + T * T + 270 * C - 330 * ee)\n                * A * A * A * A * A * A \/ 720);\n        X0 = 1000000L * (ProjNo + 1) + 500000L;\n        Y0 = 0;\n        xval = xval + X0;\n        yval = yval + Y0;\n        output[0] = xval;\n        output[1] = yval;\n        return output;\n    }\n\n    \/**\n     * \u8ba1\u7b97\u4e24\u4e2a\u70b9\u4e4b\u95f4\u7684\u8ddd\u79bb\uff08\u56fd\u6d4b\u5c4002\u5373\u706b\u661f\u5750\u6807\u7cfb\uff09\n     * @param x1\n     * @param y1\n     * @param x2\n     * @param y2\n     * @return\n     *\/\n    public static double distanceOfTwoGCJ02Points(double x1, double y1, double x2, double y2) {\n        \/\/\u706b\u661f\u5750\u6807\u8f6cwgs84\u5750\u6807\n        double[] wgsPointA = gcj02_To_Wgs84(x1, y1);\n        double[] wgsPointB = gcj02_To_Wgs84(x2, y2);\n\n        \/\/gps84\u8f6c\u9ad8\u65af6\u5ea6\u5206\u5e26\u6295\u5f71\n        double[] gaussPointA = wgs84_To_Gauss6(wgsPointA[0], wgsPointA[1]);\n        double[] gaussPointB = wgs84_To_Gauss6(wgsPointB[0], wgsPointB[1]);\n\n        GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();\n        Point a = geometryFactory.createPoint(new Coordinate(gaussPointA[0], gaussPointA[1]));\n        Point b = geometryFactory.createPoint(new Coordinate(gaussPointB[0], gaussPointB[1]));\n        return a.distance(b);\n    }\n\n    \/**\n     * \u8ba1\u7b97\u4e24\u4e2a\u70b9\u4e4b\u95f4\u7684\u8ddd\u79bb\uff08\u767e\u5ea6\u5750\u6807\u7cfb\uff0c\u5373bd09\uff09\n     * @param x1\n     * @param y1\n     * @param x2\n     * @param y2\n     * @return\n     *\/\n    public static double distanceOfTwoBaiduPoints(double x1, double y1, double x2, double y2) {\n        \/\/bd09\u5750\u6807\u8f6cwgs84\u5750\u6807\n        double[] wgsPointA = bd09_To_Wgs84(x1, y1);\n        double[] wgsPointB = bd09_To_Wgs84(x2, y2);\n\n        \/\/gps84\u8f6c\u9ad8\u65af6\u5ea6\u5206\u5e26\u6295\u5f71\n        double[] gaussPointA = wgs84_To_Gauss6(wgsPointA[0], wgsPointA[1]);\n        double[] gaussPointB = wgs84_To_Gauss6(wgsPointB[0], wgsPointB[1]);\n\n        GeodeticCalculator geodeticCalculator = new GeodeticCalculator(DefaultGeographicCRS.WGS84);\n        geodeticCalculator.setStartingGeographicPoint(wgsPointA[0], wgsPointA[1]);\n        geodeticCalculator.setDestinationGeographicPoint(wgsPointB[0], wgsPointB[1]);\n        double distance = geodeticCalculator.getOrthodromicDistance();\n        return distance;\n    }\n\n    \/**\n     * \u4e24\u6761\u7ebf\u4e4b\u95f4\u6700\u77ed\u7684\u8ddd\u79bb\n     * @param line1\n     * @param line2\n     * @return\n     *\/\n    public static double distanceOfTwoBaiduLines(LineString line1, LineString line2) {\n        double minDis = Long.MAX_VALUE;\n        long pointCount1 = line1.getCoordinates().length;\n        long pointCount2 = line2.getCoordinates().length;\n        for (int i=0; i&lt;pointCount1; i++) {\n            Coordinate point1 = line1.getCoordinateN(i);\n            for (int j = 0; j&lt;pointCount2; j++) {\n                Coordinate point2 = line2.getCoordinateN(j);\n                double temp = distanceOfTwoBaiduPoints(point1.getX(), point1.getY(), point2.getX(), point2.getY());\n                if (temp &lt; minDis) {\n                    minDis = temp;\n                }\n            }\n        }\n        return minDis;\n    }\n\n    \/**\n     * \u8ba1\u7b97\u4e24\u70b9\u95f4\u7684\u8ddd\u79bb\uff0c\u767e\u5ea6\u5750\u6807\u7cfb\uff0cbd09\n     * @param p1\n     * @param p2\n     * @return\n     *\/\n    public static double distanceOfTwoBaiduPoints(Point p1, Point p2) {\n        return distanceOfTwoBaiduPoints(p1.getX(), p1.getY(), p2.getX(), p2.getY());\n    }\n\n    @Test\n    public void testHausdorff() {\n        GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();\n        String gps1 = &quot;[{\\&quot;uploadTime\\&quot;:\\&quot;2023-11-30 02:15:41\\&quot;,\\&quot;longitude\\&quot;:117.34200831126792,\\&quot;latitude\\&quot;:39.12830255917371,\\&quot;speed\\&quot;:9,\\&quot;accumulativeMileage\\&quot;:43479},{\\&quot;uploadTime\\&quot;:\\&quot;2023-11-30 02:15:51\\&quot;,\\&quot;longitude\\&quot;:117.34164337048267,\\&quot;latitude\\&quot;:39.1282202856569,\\&quot;speed\\&quot;:14,\\&quot;accumulativeMileage\\&quot;:43479},\u3002\u3002\u3002&quot;;\n        JSONArray array1 = JSONArray.parseArray(gps1);\n        Coordinate[] coordinates1 = new Coordinate[array1.size()];\n        for (int i=0; i&lt;array1.size(); i++) {\n            JSONObject gps = array1.getJSONObject(i);\n            double lon = gps.getDoubleValue(&quot;longitude&quot;);\n            double lat = gps.getDoubleValue(&quot;latitude&quot;);\n            coordinates1[i] = new Coordinate(lon, lat);\n        }\n        LineString lineString1 = geometryFactory.createLineString(coordinates1); \/\/\u8def\u7ebf1\n\n        String gps2 = &quot;[{\\&quot;uploadTime\\&quot;:\\&quot;2023-12-01 01:49:30\\&quot;,\\&quot;longitude\\&quot;:117.34165433596777,\\&quot;latitude\\&quot;:39.12822050266268,\\&quot;speed\\&quot;:18,\\&quot;accumulativeMileage\\&quot;:43921},\u3002\u3002\u3002\u3002&quot;;\n        JSONArray array3 = JSONArray.parseArray(gps3);\n        Coordinate[] coordinates3 = new Coordinate[array3.size()];\n        for (int i=0; i&lt;array3.size(); i++) {\n            JSONObject gps = array3.getJSONObject(i);\n            double lon = gps.getDoubleValue(&quot;longitude&quot;);\n            double lat = gps.getDoubleValue(&quot;latitude&quot;);\n            coordinates3[i] = new Coordinate(lon, lat);\n        }\n        LineString lineString3 = geometryFactory.createLineString(coordinates3); \/\/\u8def\u7ebf3\uff0c\u8ddf\u7ebf\u8def1\u5b8c\u5168\u6ca1\u5173\u7cfb\n\n        Coordinate[] coordinates4 = new Coordinate[array2.size()\/2];\n        for (int i=0; i&lt;array2.size()\/2; i++) {\n            JSONObject gps = array2.getJSONObject(i);\n            double lon = gps.getDoubleValue(&quot;longitude&quot;);\n            double lat = gps.getDoubleValue(&quot;latitude&quot;);\n            coordinates4[i] = new Coordinate(lon, lat);\n        }\n        LineString lineString4 = geometryFactory.createLineString(coordinates4); \/\/\u7ebf\u8def4\uff0c\u53d6\u8def\u7ebf2\u7684\u4e00\u6bb5\n\n        HausdorffSimilarityMeasure hausdorffSimilarityMeasure = new HausdorffSimilarityMeasure();\n        double hausdorffDis = hausdorffSimilarityMeasure.measure(lineString1, lineString2);\n        log.info(&quot;hausdorff message: {}&quot;, hausdorffDis);\n\n        double hausdorffDis2 = hausdorffSimilarityMeasure.measure(lineString1, lineString3);\n        log.info(&quot;hausdorff message: {}&quot;, hausdorffDis2);\n\n        double hausdorffDis3 = hausdorffSimilarityMeasure.measure(lineString2, lineString4);\n\n        log.info(&quot;hausdorff messure: {}&quot;, hausdorffDis3);\n    }\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u9879\u76ee\u9700\u6c42\uff0c\u8981\u5bf9\u8fd0\u8425\u8f66\u8f86\u7684\u8fd0\u8425\u62a5\u8868\uff0c\u6709\u4e2a\u9700\u6c42\u662f\u6309\u7167\u8fd0\u8425\u7ebf\u8def\u7684\u7ef4\u5ea6\u8fdb\u884c\u7edf\u8ba1\uff0c\u9700\u8981\u5c06\u6240\u6709\u8f66\u8f86\u7684\u8fd0\u8425\u8f68\u8ff9\u8fdb\u884c\u7ebf\u8def\u7684\u5339\u914d\u3002\u5e73\u53f0\u4e2d\u5df2\u7ecf\u7ef4\u62a4\u4e86\u6240\u6709\u7684\u8fd0\u8425\u7ebf\u8def\uff0c\u6240\u4ee5\u53ea\u9700\u8981\u5c06\u8f66\u8f86\u8f68\u8ff9\u4e0e\u8fd0\u8425\u7ebf\u8def\u8fdb\u884c\u76f8\u4f3c\u5ea6\u8ba1\u7b97\u5c31\u53ef\u4ee5\u4e86&#46;&#46;&#46;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"pgc_sgb_lightbox_settings":"","footnotes":""},"categories":[33],"tags":[8],"class_list":["post-1561","post","type-post","status-publish","format-standard","hentry","category-coding","tag-java"],"views":626,"_links":{"self":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/1561","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1561"}],"version-history":[{"count":2,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/1561\/revisions"}],"predecessor-version":[{"id":1565,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/1561\/revisions\/1565"}],"wp:attachment":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1561"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1561"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}