本文整理汇总了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;
}
示例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;
}
示例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);
}
});
}
}
示例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;
}
示例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);
}