本文整理汇总了Java中com.spatial4j.core.distance.DistanceUtils.DEGREES_TO_RADIANS属性的典型用法代码示例。如果您正苦于以下问题:Java DistanceUtils.DEGREES_TO_RADIANS属性的具体用法?Java DistanceUtils.DEGREES_TO_RADIANS怎么用?Java DistanceUtils.DEGREES_TO_RADIANS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.spatial4j.core.distance.DistanceUtils
的用法示例。
在下文中一共展示了DistanceUtils.DEGREES_TO_RADIANS属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: distance
/**
* @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: SpatialScorer
public SpatialScorer(AtomicReaderContext readerContext, Bits acceptDocs, SpatialWeight w, float qWeight) throws IOException {
super(w);
this.weight = w;
this.qWeight = qWeight;
this.reader = readerContext.reader();
this.maxDoc = reader.maxDoc();
this.acceptDocs = acceptDocs;
latVals = latSource.getValues(weight.latContext, readerContext);
lonVals = lonSource.getValues(weight.lonContext, readerContext);
this.lonMin = SpatialDistanceQuery.this.lonMin;
this.lonMax = SpatialDistanceQuery.this.lonMax;
this.lon2Min = SpatialDistanceQuery.this.lon2Min;
this.lon2Max = SpatialDistanceQuery.this.lon2Max;
this.latMin = SpatialDistanceQuery.this.latMin;
this.latMax = SpatialDistanceQuery.this.latMax;
this.lon2 = SpatialDistanceQuery.this.lon2;
this.calcDist = SpatialDistanceQuery.this.calcDist;
this.latCenterRad = SpatialDistanceQuery.this.latCenter * DistanceUtils.DEGREES_TO_RADIANS;
this.lonCenterRad = SpatialDistanceQuery.this.lonCenter * DistanceUtils.DEGREES_TO_RADIANS;
this.latCenterRad_cos = this.calcDist ? Math.cos(latCenterRad) : 0;
this.dist = SpatialDistanceQuery.this.dist;
this.planetRadius = SpatialDistanceQuery.this.planetRadius;
}
示例3: dist
double dist(double lat, double lon) {
double latRad = lat * DistanceUtils.DEGREES_TO_RADIANS;
double lonRad = lon * DistanceUtils.DEGREES_TO_RADIANS;
// haversine, specialized to avoid a cos() call on latCenterRad
double diffX = latCenterRad - latRad;
double diffY = lonCenterRad - lonRad;
double hsinX = Math.sin(diffX * 0.5);
double hsinY = Math.sin(diffY * 0.5);
double h = hsinX * hsinX +
(latCenterRad_cos * Math.cos(latRad) * hsinY * hsinY);
double result = (planetRadius * 2 * Math.atan2(Math.sqrt(h), Math.sqrt(1 - h)));
// save the results of this calculation
lastDistDoc = doc;
lastDist = result;
return result;
}
示例4: func
@Override
public double func(int doc, FunctionValues vals) {
return vals.doubleVal(doc) * DistanceUtils.DEGREES_TO_RADIANS;
}