本文整理汇总了Java中com.spatial4j.core.shape.Rectangle.getMinX方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.getMinX方法的具体用法?Java Rectangle.getMinX怎么用?Java Rectangle.getMinX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.spatial4j.core.shape.Rectangle
的用法示例。
在下文中一共展示了Rectangle.getMinX方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getQuery
import com.spatial4j.core.shape.Rectangle; //导入方法依赖的package包/类
private Query getQuery(Function inner, Context context) {
RefLiteralPair innerPair = new RefLiteralPair(inner);
if (!innerPair.isValid()) {
return null;
}
if (innerPair.reference().valueType().equals(DataTypes.GEO_SHAPE)) {
// we have within('POINT(0 0)', shape_column)
return genericFunctionFilter(inner, context);
}
GeoPointFieldMapper.GeoPointFieldType geoPointFieldType = getGeoPointFieldType(
innerPair.reference().ident().columnIdent().fqn(),
context.mapperService);
Map<String, Object> geoJSON = (Map<String, Object>) innerPair.input().value();
Shape shape = GeoJSONUtils.map2Shape(geoJSON);
Geometry geometry = JtsSpatialContext.GEO.getGeometryFrom(shape);
IndexGeoPointFieldData fieldData = context.fieldDataService.getForField(geoPointFieldType);
if (geometry.isRectangle()) {
Rectangle boundingBox = shape.getBoundingBox();
return new InMemoryGeoBoundingBoxQuery(
new GeoPoint(boundingBox.getMaxY(), boundingBox.getMinX()),
new GeoPoint(boundingBox.getMinY(), boundingBox.getMaxX()),
fieldData
);
} else {
Coordinate[] coordinates = geometry.getCoordinates();
GeoPoint[] points = new GeoPoint[coordinates.length];
for (int i = 0; i < coordinates.length; i++) {
Coordinate coordinate = coordinates[i];
points[i] = new GeoPoint(coordinate.y, coordinate.x);
}
return new GeoPolygonQuery(fieldData, points);
}
}
示例2: GeohashPrefixTree
import com.spatial4j.core.shape.Rectangle; //导入方法依赖的package包/类
public GeohashPrefixTree(SpatialContext ctx, int maxLevels) {
super(ctx, maxLevels);
Rectangle bounds = ctx.getWorldBounds();
if (bounds.getMinX() != -180)
throw new IllegalArgumentException("Geohash only supports lat-lon world bounds. Got "+bounds);
int MAXP = getMaxLevelsPossible();
if (maxLevels <= 0 || maxLevels > MAXP)
throw new IllegalArgumentException("maxLen must be [1-"+MAXP+"] but got "+ maxLevels);
}
示例3: QuadPrefixTree
import com.spatial4j.core.shape.Rectangle; //导入方法依赖的package包/类
public QuadPrefixTree(
SpatialContext ctx, Rectangle bounds, int maxLevels) {
super(ctx, maxLevels);
this.xmin = bounds.getMinX();
this.xmax = bounds.getMaxX();
this.ymin = bounds.getMinY();
this.ymax = bounds.getMaxY();
levelW = new double[maxLevels];
levelH = new double[maxLevels];
levelS = new int[maxLevels];
levelN = new int[maxLevels];
gridW = xmax - xmin;
gridH = ymax - ymin;
this.xmid = xmin + gridW/2.0;
this.ymid = ymin + gridH/2.0;
levelW[0] = gridW/2.0;
levelH[0] = gridH/2.0;
levelS[0] = 2;
levelN[0] = 4;
for (int i = 1; i < levelW.length; i++) {
levelW[i] = levelW[i - 1] / 2.0;
levelH[i] = levelH[i - 1] / 2.0;
levelS[i] = levelS[i - 1] * 2;
levelN[i] = levelN[i - 1] * 4;
}
}
示例4: createIndexableFields
import com.spatial4j.core.shape.Rectangle; //导入方法依赖的package包/类
public Field[] createIndexableFields(Rectangle bbox) {
Field[] fields = new Field[5];
fields[0] = new ComboField(field_minX, bbox.getMinX(), fieldType);
fields[1] = new ComboField(field_maxX, bbox.getMaxX(), fieldType);
fields[2] = new ComboField(field_minY, bbox.getMinY(), fieldType);
fields[3] = new ComboField(field_maxY, bbox.getMaxY(), fieldType);
fields[4] = new ComboField(field_xdl, bbox.getCrossesDateLine()?"T":"F", xdlFieldType);
return fields;
}
示例5: randomIndexedShape
import com.spatial4j.core.shape.Rectangle; //导入方法依赖的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);
}
示例6: bufferShape
import com.spatial4j.core.shape.Rectangle; //导入方法依赖的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);
}
}
示例7: checkHits
import com.spatial4j.core.shape.Rectangle; //导入方法依赖的package包/类
private void checkHits(String fieldName, boolean exact, String ptStr, double distKM, int count, int ... docIds) throws ParseException {
if (exact && fieldName.equalsIgnoreCase("bbox")) {
return; // bbox field only supports rectangular query
}
String [] tests = new String[docIds != null && docIds.length > 0 ? docIds.length + 1 : 1];
//test for presence of required ids first
int i = 0;
if (docIds != null && docIds.length > 0) {
for (int docId : docIds) {
tests[i++] = "//result/doc/*[@name='id'][.='" + docId + "']";
}
}
//check total length last; maybe response includes ids it shouldn't. Nicer to check this last instead of first so
// that there may be a more specific detailed id to investigate.
tests[i++] = "*[count(//doc)=" + count + "]";
//Test using the Lucene spatial syntax
{
//never actually need the score but lets test
String score = new String[]{null, "none","distance","recipDistance"}[random().nextInt(4)];
double distDEG = DistanceUtils.dist2Degrees(distKM, DistanceUtils.EARTH_MEAN_RADIUS_KM);
Point point = SpatialUtils.parsePoint(ptStr, SpatialContext.GEO);
String circleStr = "BUFFER(POINT(" + point.getX()+" "+point.getY()+")," + distDEG + ")";
String shapeStr;
if (exact) {
shapeStr = circleStr;
} else {//bbox
//the GEO is an assumption
SpatialContext ctx = SpatialContext.GEO;
Rectangle bbox = ctx.readShapeFromWkt(circleStr).getBoundingBox();
shapeStr = "ENVELOPE(" + bbox.getMinX() + ", " + bbox.getMaxX() +
", " + bbox.getMaxY() + ", " + bbox.getMinY() + ")";
}
//FYI default distErrPct=0.025 works with the tests in this file
assertQ(req(
"fl", "id", "q","*:*", "rows", "1000",
"fq", "{!field f=" + fieldName + (score==null?"":" score="+score)
+ "}Intersects(" + shapeStr + ")"),
tests);
}
//Test using geofilt
{
assertQ(req(
"fl", "id", "q", "*:*", "rows", "1000",
"fq", "{!" + (exact ? "geofilt" : "bbox") + " sfield=" + fieldName + " pt='" + ptStr + "' d=" + distKM + "}"),
tests);
}
}