本文整理汇总了Java中com.spatial4j.core.shape.Point.getX方法的典型用法代码示例。如果您正苦于以下问题:Java Point.getX方法的具体用法?Java Point.getX怎么用?Java Point.getX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.spatial4j.core.shape.Point
的用法示例。
在下文中一共展示了Point.getX方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeShape
import com.spatial4j.core.shape.Point; //导入方法依赖的package包/类
@Override
public Rectangle makeShape(OCompositeKey key, SpatialContext ctx) {
Point[] points = new Point[2];
int i = 0;
for (Object o : key.getKeys()) {
List<Number> numbers = (List<Number>) o;
double lat = ((Double) OType.convert(numbers.get(0), Double.class)).doubleValue();
double lng = ((Double) OType.convert(numbers.get(1), Double.class)).doubleValue();
points[i] = ctx.makePoint(lng, lat);
i++;
}
Point lowerLeft = points[0];
Point topRight = points[1];
if (lowerLeft.getX() > topRight.getX()) {
double x = lowerLeft.getX();
lowerLeft = ctx.makePoint(topRight.getX(), lowerLeft.getY());
topRight = ctx.makePoint(x, topRight.getY());
}
return ctx.makeRectangle(lowerLeft, topRight);
}
示例2: pointFromString
import com.spatial4j.core.shape.Point; //导入方法依赖的package包/类
private static Double[] pointFromString(String value) {
try {
Point point = (Point)SPATIAL_CONTEXT.readShapeFromWkt(value);
return new Double[] {point.getX(), point.getY()};
} catch (ParseException e) {
throw new IllegalArgumentException(String.format(Locale.ENGLISH,
"Cannot convert \"%s\" to geo_point", value), e);
}
}
示例3: createIndexableFields
import com.spatial4j.core.shape.Point; //导入方法依赖的package包/类
/** @see #createIndexableFields(com.spatial4j.core.shape.Shape) */
public Field[] createIndexableFields(Point point) {
FieldType doubleFieldType = new FieldType(DoubleField.TYPE_NOT_STORED);
doubleFieldType.setNumericPrecisionStep(precisionStep);
Field[] f = new Field[2];
f[0] = new DoubleField(fieldNameX, point.getX(), doubleFieldType);
f[1] = new DoubleField(fieldNameY, point.getY(), doubleFieldType);
return f;
}
示例4: toExternal
import com.spatial4j.core.shape.Point; //导入方法依赖的package包/类
@Override
public String toExternal(IndexableField f) {
Point p = GeohashUtils.decode(f.stringValue(), SpatialContext.GEO);
return p.getY() + "," + p.getX();
}
示例5: checkHits
import com.spatial4j.core.shape.Point; //导入方法依赖的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);
}
}
示例6: toExternal
import com.spatial4j.core.shape.Point; //导入方法依赖的package包/类
@Override
public String toExternal(IndexableField f) {
Point p = GeohashUtils.decode(f.stringValue(),ctx);
return p.getY() + "," + p.getX();
}
示例7: geoHashToPoint
import com.spatial4j.core.shape.Point; //导入方法依赖的package包/类
/**
* Returns the X and Y point for the geohash. Element 0 is the X (longitude)
* element 1 is the Y (latitude)
*
* @param geohash
* @return
*/
public double[] geoHashToPoint(String geohash) {
Point decode = GeohashUtils.decode(geohash, SpatialContext.GEO);
double[] coords = new double[]{decode.getX(), decode.getY()};
return coords;
}
示例8: geoHashToPointStr
import com.spatial4j.core.shape.Point; //导入方法依赖的package包/类
/**
* Returns the X and Y point for the geohash. Element 0 is the X (longitude)
* element 1 is the Y (latitude)
*
* @param geohash
* @return
*/
public String geoHashToPointStr(String geohash) {
Point decode = GeohashUtils.decode(geohash, SpatialContext.GEO);
String point = decode.getX() + "," + decode.getY();
return point;
}