当前位置: 首页>>代码示例>>Java>>正文


Java DistanceUtils.DEGREES_TO_RADIANS属性代码示例

本文整理汇总了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;
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:HaversineFunction.java

示例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;

}
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:LatLonType.java

示例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;
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:LatLonType.java

示例4: func

@Override
public double func(int doc, FunctionValues vals) {
  return vals.doubleVal(doc) * DistanceUtils.DEGREES_TO_RADIANS;
}
 
开发者ID:europeana,项目名称:search,代码行数:4,代码来源:ValueSourceParser.java


注:本文中的com.spatial4j.core.distance.DistanceUtils.DEGREES_TO_RADIANS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。