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


Java DistanceUtils.normLonDEG方法代码示例

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


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

示例1: randomIndexedShape

import com.spatial4j.core.distance.DistanceUtils; //导入方法依赖的package包/类
@Override
protected Shape randomIndexedShape() {
  Rectangle world = ctx.getWorldBounds();
  if (random().nextInt(10) == 0) // increased chance of getting one of these
    return world;

  int worldWidth = (int) Math.round(world.getWidth());
  int deltaLeft = nextIntInclusive(worldWidth);
  int deltaRight = nextIntInclusive(worldWidth - deltaLeft);
  int worldHeight = (int) Math.round(world.getHeight());
  int deltaTop = nextIntInclusive(worldHeight);
  int deltaBottom = nextIntInclusive(worldHeight - deltaTop);

  double rectMinX = world.getMinX() + deltaLeft;
  double rectMaxX = world.getMaxX() - deltaRight;
  if (ctx.isGeo()) {
    int shift = 0;
    if ((deltaLeft != 0 || deltaRight != 0)) {
      //if geo & doesn't world-wrap, we shift randomly to potentially cross dateline
      shift = nextIntInclusive(360);
    }
    rectMinX = DistanceUtils.normLonDEG(rectMinX + shift);
    rectMaxX = DistanceUtils.normLonDEG(rectMaxX + shift);
    if (rectMinX == 180 && rectMaxX == 180) {
      // Work-around for https://github.com/spatial4j/spatial4j/issues/85
      rectMinX = -180;
      rectMaxX = -180;
    }
  }
  return ctx.makeRectangle(
      rectMinX,
      rectMaxX,
      world.getMinY() + deltaBottom, world.getMaxY() - deltaTop);
}
 
开发者ID:europeana,项目名称:search,代码行数:35,代码来源:TestBBoxStrategy.java

示例2: bufferShape

import com.spatial4j.core.distance.DistanceUtils; //导入方法依赖的package包/类
/** Returns a new shape that is larger than shape by at distErr.
 */
//TODO move this generic code elsewhere?  Spatial4j?
protected Shape bufferShape(Shape shape, double distErr) {
  if (distErr <= 0)
    throw new IllegalArgumentException("distErr must be > 0");
  SpatialContext ctx = grid.getSpatialContext();
  if (shape instanceof Point) {
    return ctx.makeCircle((Point)shape, distErr);
  } else if (shape instanceof Circle) {
    Circle circle = (Circle) shape;
    double newDist = circle.getRadius() + distErr;
    if (ctx.isGeo() && newDist > 180)
      newDist = 180;
    return ctx.makeCircle(circle.getCenter(), newDist);
  } else {
    Rectangle bbox = shape.getBoundingBox();
    double newMinX = bbox.getMinX() - distErr;
    double newMaxX = bbox.getMaxX() + distErr;
    double newMinY = bbox.getMinY() - distErr;
    double newMaxY = bbox.getMaxY() + distErr;
    if (ctx.isGeo()) {
      if (newMinY < -90)
        newMinY = -90;
      if (newMaxY > 90)
        newMaxY = 90;
      if (newMinY == -90 || newMaxY == 90 || bbox.getWidth() + 2*distErr > 360) {
        newMinX = -180;
        newMaxX = 180;
      } else {
        newMinX = DistanceUtils.normLonDEG(newMinX);
        newMaxX = DistanceUtils.normLonDEG(newMaxX);
      }
    } else {
      //restrict to world bounds
      newMinX = Math.max(newMinX, ctx.getWorldBounds().getMinX());
      newMaxX = Math.min(newMaxX, ctx.getWorldBounds().getMaxX());
      newMinY = Math.max(newMinY, ctx.getWorldBounds().getMinY());
      newMaxY = Math.min(newMaxY, ctx.getWorldBounds().getMaxY());
    }
    return ctx.makeRectangle(newMinX, newMaxX, newMinY, newMaxY);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:44,代码来源:WithinPrefixTreeFilter.java


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