Commit f97a68dd by yangyang

轨迹相似度调整提交(标准)

parent 68ef61a2
......@@ -15,7 +15,7 @@ public class LCSS {
}
public boolean isNearby(Coordinate a, Coordinate b,int radius) {
if (getDistance(a, b) < radius) return true;
if (getDistance(a.getX(), a.getY(), b.getX(), b.getY()) < radius) return true;
return false;
}
......@@ -74,16 +74,19 @@ public class LCSS {
//归一化处理
return map;
}
public static void main(String[] args) {
List<Coordinate> l1 = new ArrayList<>();
l1.add(new Coordinate(114.300, 30.1,"1647927276000"));
l1.add(new Coordinate(114.302, 30.101,"1648048592000"));
List<Coordinate> l2 = new ArrayList<>();
l2.add(new Coordinate(109.304, 30.1003,"1648048572000"));
l2.add(new Coordinate(109.302, 30.101,"1648048545000"));
LCSS lcss = new LCSS();
System.out.println(lcss.lcs(l1, l2,10,1));
private static double EARTH_RADIUS = 6371.393;
private static double rad(double d) {
return d * Math.PI / 180.0;
}
public static double getDistance(double lat1, double lng1, double lat2, double lng2) {
double radLat1 = rad(lat1);
double radLat2 = rad(lat2);
double a = radLat1 - radLat2;
double b = rad(lng1) - rad(lng2);
double s = 2 * Math.asin(Math.sqrt(Math.abs(
Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))));
s = s * EARTH_RADIUS;
s = Math.round(s * 1000);
return s;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment