• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Circle类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.spatial4j.core.shape.Circle的典型用法代码示例。如果您正苦于以下问题:Java Circle类的具体用法?Java Circle怎么用?Java Circle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Circle类属于com.spatial4j.core.shape包,在下文中一共展示了Circle类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: writeShape

import com.spatial4j.core.shape.Circle; //导入依赖的package包/类
/** Overloaded to provide a number format. */
public String writeShape(Shape shape, NumberFormat nf) {
  if (shape instanceof Point) {
    Point point = (Point) shape;
    return nf.format(point.getX()) + " " + nf.format(point.getY());
  } else if (shape instanceof Rectangle) {
    Rectangle rect = (Rectangle) shape;
    return nf.format(rect.getMinX()) + " " + nf.format(rect.getMinY()) + " " + nf.format(rect.getMaxX()) + " "
        + nf.format(rect.getMaxY());
  } else if (shape instanceof Circle) {
    Circle c = (Circle) shape;
    return "Circle(" + nf.format(c.getCenter().getX()) + " " + nf.format(c.getCenter().getY()) + " " + "d="
        + nf.format(c.getRadius()) + ")";
  }
  return shape.toString();
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:17,代码来源:ShapeReadWriter.java


示例2: test28

import com.spatial4j.core.shape.Circle; //导入依赖的package包/类
@Test
public void test28() throws ParseException {
  SpatialContext ctx = SpatialContext.GEO;
  ShapeReadWriter<SpatialContext> shapeReadWriter = new ShapeReadWriter<SpatialContext>(ctx);
  int maxLevels = 11;
  SpatialPrefixTree grid = new GeohashPrefixTree(ctx, maxLevels);
  RecursivePrefixTreeStrategy strategy = new RecursivePrefixTreeStrategy(grid, "a.id_gis", false);
  Circle circle = ctx.makeCircle(-80.0, 33.0, DistanceUtils.dist2Degrees(10, DistanceUtils.EARTH_MEAN_RADIUS_KM));
  SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, circle);

  String writeSpatialArgs = SpatialArgsParser.writeSpatialArgs(args, shapeReadWriter);

  // This has to be done because of rounding.
  SpatialArgs spatialArgs = SpatialArgsParser.parse(writeSpatialArgs, shapeReadWriter);
  Query q1 = sq(strategy.makeQuery(spatialArgs));
  Query q = parseSq("a.id_gis:\"" + writeSpatialArgs + "\"");
  boolean equals = q1.equals(q);
  assertTrue(equals);
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:20,代码来源:SuperParserTest.java


示例3: evaluateRecord

import com.spatial4j.core.shape.Circle; //导入依赖的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


示例4: testCircleShapeSupport

import com.spatial4j.core.shape.Circle; //导入依赖的package包/类
@Test
public void testCircleShapeSupport() {
  Circle circle = ctx.makeCircle(ctx.makePoint(0, 0), 10);
  SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, circle);
  Query query = this.strategy.makeQuery(args);

  assertNotNull(query);
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:TestPointVectorStrategy.java


示例5: evaluateRecord

import com.spatial4j.core.shape.Circle; //导入依赖的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


示例6: test29

import com.spatial4j.core.shape.Circle; //导入依赖的package包/类
@Test
public void test29() throws ParseException {
  SpatialContext ctx = SpatialContext.GEO;
  int maxLevels = 11;
  SpatialPrefixTree grid = new GeohashPrefixTree(ctx, maxLevels);
  RecursivePrefixTreeStrategy strategy = new RecursivePrefixTreeStrategy(grid, "a.id_gis", false);
  Circle circle = ctx.makeCircle(-80.0, 33.0, DistanceUtils.dist2Degrees(10, DistanceUtils.EARTH_MEAN_RADIUS_KM));
  SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, circle);

  Query q1 = sq(strategy.makeQuery(args));
  Query q = parseSq("a.id_gis:\"Intersects(Circle(33.000000,-80.000000 d=10.0km))\"");
  boolean equals = q1.equals(q);
  assertTrue(equals);
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:15,代码来源:SuperParserTest.java


示例7: test30

import com.spatial4j.core.shape.Circle; //导入依赖的package包/类
@Test
public void test30() throws ParseException {
  SpatialContext ctx = SpatialContext.GEO;
  int maxLevels = 11;
  SpatialPrefixTree grid = new GeohashPrefixTree(ctx, maxLevels);
  RecursivePrefixTreeStrategy strategy = new RecursivePrefixTreeStrategy(grid, "a.id_gis", false);
  Circle circle = ctx.makeCircle(-80.0, 33.0, DistanceUtils.dist2Degrees(10, DistanceUtils.EARTH_MEAN_RADIUS_MI));
  SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, circle);

  Query q1 = sq(strategy.makeQuery(args));
  Query q = parseSq("a.id_gis:\"Intersects(Circle(33.000000,-80.000000 d=10.0m))\"");
  boolean equals = q1.equals(q);
  assertTrue(equals);
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:15,代码来源:SuperParserTest.java


示例8: test45

import com.spatial4j.core.shape.Circle; //导入依赖的package包/类
@Test
public void test45() throws ParseException {
  SpatialContext ctx = SpatialContext.GEO;
  int maxLevels = 11;
  SpatialPrefixTree grid = new GeohashPrefixTree(ctx, maxLevels);
  RecursivePrefixTreeStrategy strategy = new RecursivePrefixTreeStrategy(grid, "a.id_gis", false);
  Circle circle = ctx.makeCircle(-80.0, 33.0, DistanceUtils.dist2Degrees(10, DistanceUtils.EARTH_MEAN_RADIUS_MI));
  SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, circle);

  Query q1 = sq(bq(bc_m(strategy.makeQuery(args))));
  Query q = parseSq("<+a.id_gis:\"Intersects(Circle(33.000000,-80.000000 d=10.0m))\">");
  boolean equals = q1.equals(q);
  assertTrue(equals);
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:15,代码来源:SuperParserTest.java


示例9: test46

import com.spatial4j.core.shape.Circle; //导入依赖的package包/类
@Test
public void test46() throws ParseException {
  SpatialContext ctx = SpatialContext.GEO;
  int maxLevels = 11;
  SpatialPrefixTree grid = new GeohashPrefixTree(ctx, maxLevels);
  RecursivePrefixTreeStrategy strategy = new RecursivePrefixTreeStrategy(grid, "a.id_gis", false);
  Circle circle = ctx.makeCircle(-80.0, 33.0, DistanceUtils.dist2Degrees(10, DistanceUtils.EARTH_MEAN_RADIUS_MI));
  SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, circle);

  Query q1 = sq(bq(bc_m(strategy.makeQuery(args)), bc(tq("rowid", "12345"))));
  Query q = parseSq("<+a.id_gis:\"Intersects(Circle(33.000000,-80.000000 d=10.0m))\" rowid:12345>");
  boolean equals = q1.equals(q);
  assertTrue(equals);
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:15,代码来源:SuperParserTest.java


示例10: test47

import com.spatial4j.core.shape.Circle; //导入依赖的package包/类
@Test
public void test47() throws ParseException {
  SpatialContext ctx = SpatialContext.GEO;
  int maxLevels = 11;
  SpatialPrefixTree grid = new GeohashPrefixTree(ctx, maxLevels);
  RecursivePrefixTreeStrategy strategy = new RecursivePrefixTreeStrategy(grid, "a.id_gis", false);
  Circle circle = ctx.makeCircle(-80.0, 33.0, DistanceUtils.dist2Degrees(10, DistanceUtils.EARTH_MEAN_RADIUS_MI));
  SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, circle);

  Query q1 = sq(strategy.makeQuery(args));
  Query q = parseSq("<a.id_gis:\"Intersects(Circle(33.000000,-80.000000 d=10.0m))\">");
  boolean equals = q1.equals(q);
  assertTrue(equals);
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:15,代码来源:SuperParserTest.java


示例11: build

import com.spatial4j.core.shape.Circle; //导入依赖的package包/类
@Override
public Circle build() {
    return SPATIAL_CONTEXT.makeCircle(center.x, center.y, 360 * radius / unit.getEarthCircumference());
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:5,代码来源:CircleBuilder.java


示例12: bufferShape

import com.spatial4j.core.shape.Circle; //导入依赖的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.shape.Circle类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CameraFacing类代码示例发布时间:2022-05-23
下一篇:
Java ClientSession类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap