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


Java DistanceUtils.degrees2Dist方法代码示例

本文整理汇总了Java中com.spatial4j.core.distance.DistanceUtils.degrees2Dist方法的典型用法代码示例。如果您正苦于以下问题:Java DistanceUtils.degrees2Dist方法的具体用法?Java DistanceUtils.degrees2Dist怎么用?Java DistanceUtils.degrees2Dist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.spatial4j.core.distance.DistanceUtils的用法示例。


在下文中一共展示了DistanceUtils.degrees2Dist方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDistance

import com.spatial4j.core.distance.DistanceUtils; //导入方法依赖的package包/类
/**
 * Returns distance (in meters) between 2 points.
 *
 * @param point1 Must not be null
 * @param point2 Must not be null
 * @return distance in meters
 */
public static double getDistance(Point point1, Point point2) {
	Assert.notNull(point1, "point1 must not be null");
	Assert.notNull(point2, "point2 must not be null");

	final SpatialContext ctx = SpatialContext.GEO;
	com.spatial4j.core.shape.Point p1 = ctx.makePoint(point1.getLongitude(), point1.getLatitude());
	com.spatial4j.core.shape.Point p2 = ctx.makePoint(point2.getLongitude(), point2.getLatitude());

	return DistanceUtils.degrees2Dist(ctx.getDistCalc().distance(p1, p2), DistanceUtils.EARTH_MEAN_RADIUS_KM) * 1000;
}
 
开发者ID:ghillert,项目名称:gps-vehicle-simulator,代码行数:18,代码来源:NavUtils.java

示例2: evaluateRecord

import com.spatial4j.core.distance.DistanceUtils; //导入方法依赖的package包/类
@Override
public Object evaluateRecord(OIdentifiable iRecord, ODocument iCurrentResult, OSQLFilterCondition iCondition, Object iLeft,
    Object iRight, OCommandContext iContext) {

  List<Number> left = (List<Number>) iLeft;

  double lat = left.get(0).doubleValue();
  double lon = left.get(1).doubleValue();

  Shape shape = factory.context().makePoint(lon, lat);
  List<Number> right = (List<Number>) iRight;

  double lat1 = right.get(0).doubleValue();
  double lon1 = right.get(1).doubleValue();
  Shape shape1 = factory.context().makePoint(lon1, lat1);

  Map map = (Map) right.get(2);
  double distance = 0;

  Number n = (Number) map.get("maxDistance");
  if (n != null) {
    distance = n.doubleValue();
  }
  Point p = (Point) shape1;
  Circle circle = factory.context().makeCircle(p.getX(), p.getY(),
      DistanceUtils.dist2Degrees(distance, DistanceUtils.EARTH_MEAN_RADIUS_KM));
  double docDistDEG = factory.context().getDistCalc().distance((Point) shape, p);
  final double docDistInKM = DistanceUtils.degrees2Dist(docDistDEG, DistanceUtils.EARTH_EQUATORIAL_RADIUS_KM);
  iContext.setVariable("distance", docDistInKM);
  return shape.relate(circle) == SpatialRelation.WITHIN;
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:32,代码来源:OLuceneNearOperator.java

示例3: onRecordAddedToResultSet

import com.spatial4j.core.distance.DistanceUtils; //导入方法依赖的package包/类
@Override
public void onRecordAddedToResultSet(QueryContext queryContext, OContextualRecordId recordId, Document doc, ScoreDoc score) {

  SpatialQueryContext spatialContext = (SpatialQueryContext) queryContext;
  if (spatialContext.spatialArgs != null) {
    Point docPoint = (Point) ctx.readShape(doc.get(strategy.getFieldName()));
    double docDistDEG = ctx.getDistCalc().distance(spatialContext.spatialArgs.getShape().getCenter(), docPoint);
    final double docDistInKM = DistanceUtils.degrees2Dist(docDistDEG, DistanceUtils.EARTH_EQUATORIAL_RADIUS_KM);
    recordId.setContext(new HashMap<String, Object>() {
      {
        put("distance", docDistInKM);
      }
    });
  }
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:16,代码来源:OLuceneLegacySpatialIndexEngine.java

示例4: evaluateRecord

import com.spatial4j.core.distance.DistanceUtils; //导入方法依赖的package包/类
@Override
public Object evaluateRecord(OIdentifiable iRecord, ODocument iCurrentResult, OSQLFilterCondition iCondition, Object iLeft,
    Object iRight, OCommandContext iContext) {

  List<Number> left = (List<Number>) iLeft;

  double lat = left.get(0).doubleValue();
  double lon = left.get(1).doubleValue();

  Shape shape = SpatialContext.GEO.makePoint(lon, lat);
  List<Number> right = (List<Number>) iRight;

  double lat1 =  right.get(0).doubleValue();
  double lon1 =  right.get(1).doubleValue();
  Shape shape1 = SpatialContext.GEO.makePoint(lon1, lat1);

  Map map = (Map) right.get(2);
  double distance = 0;

  Number n = (Number) map.get("maxDistance");
  if (n != null) {
    distance = n.doubleValue();
  }
  Point p = (Point) shape1;
  Circle circle = SpatialContext.GEO.makeCircle(p.getX(), p.getY(),
      DistanceUtils.dist2Degrees(distance, DistanceUtils.EARTH_MEAN_RADIUS_KM));
  double docDistDEG = SpatialContext.GEO.getDistCalc().distance((Point) shape, p);
  final double docDistInKM = DistanceUtils.degrees2Dist(docDistDEG, DistanceUtils.EARTH_EQUATORIAL_RADIUS_KM);
  iContext.setVariable("distance", docDistInKM);
  return shape.relate(circle) == SpatialRelation.WITHIN;
}
 
开发者ID:orientechnologies,项目名称:orientdb-lucene,代码行数:32,代码来源:OLuceneNearOperator.java

示例5: distance

import com.spatial4j.core.distance.DistanceUtils; //导入方法依赖的package包/类
/**
 * Returns the distance to another point in kilometers
 *
 * @param other Point
 * @return
 */
public double distance(Point other) {
    return DistanceUtils.degrees2Dist(CTX.getDistCalc().distance(getSpatial4jPoint(),other.getSpatial4jPoint()),DistanceUtils.EARTH_MEAN_RADIUS_KM);
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:10,代码来源:Geoshape.java


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