本文整理汇总了Java中com.spatial4j.core.context.SpatialContext.makeCircle方法的典型用法代码示例。如果您正苦于以下问题:Java SpatialContext.makeCircle方法的具体用法?Java SpatialContext.makeCircle怎么用?Java SpatialContext.makeCircle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.spatial4j.core.context.SpatialContext
的用法示例。
在下文中一共展示了SpatialContext.makeCircle方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calcDistanceFromErrPct
import com.spatial4j.core.context.SpatialContext; //导入方法依赖的package包/类
@Test
public void calcDistanceFromErrPct() {
final SpatialContext ctx = SpatialContext.GEO;
final double DEP = 0.5;//distErrPct
//the result is the diagonal distance from the center to the closest corner,
// times distErrPct
Shape superwide = ctx.makeRectangle(-180, 180, 0, 0);
//0 distErrPct means 0 distance always
assertEquals(0, SpatialArgs.calcDistanceFromErrPct(superwide, 0, ctx), 0);
assertEquals(180 * DEP, SpatialArgs.calcDistanceFromErrPct(superwide, DEP, ctx), 0);
Shape supertall = ctx.makeRectangle(0, 0, -90, 90);
assertEquals(90 * DEP, SpatialArgs.calcDistanceFromErrPct(supertall, DEP, ctx), 0);
Shape upperhalf = ctx.makeRectangle(-180, 180, 0, 90);
assertEquals(45 * DEP, SpatialArgs.calcDistanceFromErrPct(upperhalf, DEP, ctx), 0.0001);
Shape midCircle = ctx.makeCircle(0, 0, 45);
assertEquals(60 * DEP, SpatialArgs.calcDistanceFromErrPct(midCircle, DEP, ctx), 0.0001);
}
示例2: test28
import com.spatial4j.core.context.SpatialContext; //导入方法依赖的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);
}
示例3: toSpatial4j
import com.spatial4j.core.context.SpatialContext; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Shape toSpatial4j(SpatialContext spatialContext) {
double kms = distance.getValue(GeoDistanceUnit.KILOMETRES);
double d = DistanceUtils.dist2Degrees(kms, DistanceUtils.EARTH_MEAN_RADIUS_KM);
return spatialContext.makeCircle(longitude, latitude, d);
}
示例4: test29
import com.spatial4j.core.context.SpatialContext; //导入方法依赖的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);
}
示例5: test30
import com.spatial4j.core.context.SpatialContext; //导入方法依赖的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);
}
示例6: test45
import com.spatial4j.core.context.SpatialContext; //导入方法依赖的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);
}
示例7: test46
import com.spatial4j.core.context.SpatialContext; //导入方法依赖的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);
}
示例8: test47
import com.spatial4j.core.context.SpatialContext; //导入方法依赖的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);
}
示例9: bufferShape
import com.spatial4j.core.context.SpatialContext; //导入方法依赖的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);
}
}