本文整理汇总了Java中com.spatial4j.core.distance.DistanceUtils.distHaversineRAD方法的典型用法代码示例。如果您正苦于以下问题:Java DistanceUtils.distHaversineRAD方法的具体用法?Java DistanceUtils.distHaversineRAD怎么用?Java DistanceUtils.distHaversineRAD使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.spatial4j.core.distance.DistanceUtils
的用法示例。
在下文中一共展示了DistanceUtils.distHaversineRAD方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: distance
import com.spatial4j.core.distance.DistanceUtils; //导入方法依赖的package包/类
/**
* @param doc The doc to score
* @return The haversine distance formula
*/
protected double distance(int doc, FunctionValues p1DV, FunctionValues p2DV) {
double[] p1D = new double[2];
double[] p2D = new double[2];
p1DV.doubleVal(doc, p1D);
p2DV.doubleVal(doc, p2D);
double y1;
double x1;
double y2;
double x2;
if (convertToRadians) {
y1 = p1D[0] * DistanceUtils.DEGREES_TO_RADIANS;
x1 = p1D[1] * DistanceUtils.DEGREES_TO_RADIANS;
y2 = p2D[0] * DistanceUtils.DEGREES_TO_RADIANS;
x2 = p2D[1] * DistanceUtils.DEGREES_TO_RADIANS;
} else {
y1 = p1D[0];
x1 = p1D[1];
y2 = p2D[0];
x2 = p2D[1];
}
return DistanceUtils.distHaversineRAD(y1,x1,y2,x2)*radius;
}
示例2: shouldCluster
import com.spatial4j.core.distance.DistanceUtils; //导入方法依赖的package包/类
public boolean shouldCluster(Bucket bucket, Bucket bucket2) {
double lat1 = bucket.getClusterCenter().getLat();
double lon1 = bucket.getClusterCenter().getLon();
double lat2 = bucket2.getClusterCenter().getLat();
double lon2 = bucket2.getClusterCenter().getLon();
double curDistance = GeoUtils.EARTH_MEAN_RADIUS * DistanceUtils.distHaversineRAD(DistanceUtils.toRadians(lat1), DistanceUtils.toRadians(lon1), DistanceUtils.toRadians(lat2), DistanceUtils.toRadians(lon2));
double meterByPixel = GeoClusterUtils.getMeterByPixel(zoom, (lat1 + lat2) / 2 );
return distance >= curDistance / meterByPixel;
}
开发者ID:opendatasoft,项目名称:elasticsearch-aggregation-geoclustering,代码行数:14,代码来源:InternalGeoHashClustering.java