@Test public void testCalDistanceMatrixMatrix() { FastDistanceMatrixData matrixData = initMatrixData(); DenseMatrix res = distance.calc(matrixData, matrixData); double[] expect = new double[] {0.0, 5160.251, 5160.251, 0.0}; double[] predict = res.getData(); for (int i = 0; i < expect.length; i++) { Assert.assertEquals(expect[i], predict[i], 0.01); } }
public double calc(double latitude1, double longitude1, double latitude2, double longitude2) { double lat1 = degreeToRadian(latitude1); double lon1 = degreeToRadian(longitude1); double lat2 = degreeToRadian(latitude2); double lon2 = degreeToRadian(longitude2); double vLat = lat2 - lat1; double vLon = lon2 - lon1; double h = haverSine(vLat) + Math.cos(lat1) * Math.cos(lat2) * haverSine(vLon); return cal(h); }
HaversineDistance extends FastDistance { public double calc(double latitude1, double longitude1, double latitude2, double longitude2) { double lat1 = degreeToRadian(latitude1); double lon1 = degreeToRadian(longitude1); double lat2 = degreeToRadian(latitude2); double lon2 = degreeToRadian(longitude2); double vLat = lat2 - lat1; double vLon = lon2 - lon1; double h = haverSine(vLat) + Math.cos(lat1) * Math.cos(lat2) * haverSine(vLon); return cal(h); } }
HaversineDistance extends FastDistance { public double calc(double latitude1, double longitude1, double latitude2, double longitude2) { double lat1 = degreeToRadian(latitude1); double lon1 = degreeToRadian(longitude1); double lat2 = degreeToRadian(latitude2); double lon2 = degreeToRadian(longitude2); double vLat = lat2 - lat1; double vLon = lon2 - lon1; double h = haverSine(vLat) + Math.cos(lat1) * Math.cos(lat2) * haverSine(vLon); return cal(h); }  }
HaversineDistance extends FastDistance { public double calc(double latitude1, double longitude1, double latitude2, double longitude2) { double lat1 = degreeToRadian(latitude1); double lon1 = degreeToRadian(longitude1); double lat2 = degreeToRadian(latitude2); double lon2 = degreeToRadian(longitude2); double vLat = lat2 - lat1; double vLon = lon2 - lon1; double h = haverSine(vLat) + Math.cos(lat1) * Math.cos(lat2) * haverSine(vLon); return cal(h); }  double calc(double latitude1, double longitude1, double latitude2, double longitude2); @Override double calc(double[] array1, double[] array2); @Override double calc(Vector vec1, Vector vec2); @Override void updateLabel(FastDistanceData data); }
HaversineDistance extends FastDistance { public double calc(double latitude1, double longitude1, double latitude2, double longitude2) { double lat1 = degreeToRadian(latitude1); double lon1 = degreeToRadian(longitude1); double lat2 = degreeToRadian(latitude2); double lon2 = degreeToRadian(longitude2); double vLat = lat2 - lat1; double vLon = lon2 - lon1; double h = haverSine(vLat) + Math.cos(lat1) * Math.cos(lat2) * haverSine(vLon); return cal(h); }  double calc(double latitude1, double longitude1, double latitude2, double longitude2); @Override double calc(double[] array1, double[] array2); @Override double calc(Vector vec1, Vector vec2); @Override void updateLabel(FastDistanceData data);  }