本文整理了Java中org.apache.lucene.geo.GeoEncodingUtils.decodeLongitude()
方法的一些代码示例,展示了GeoEncodingUtils.decodeLongitude()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GeoEncodingUtils.decodeLongitude()
方法的具体详情如下:
包路径:org.apache.lucene.geo.GeoEncodingUtils
类名称:GeoEncodingUtils
方法名:decodeLongitude
[英]Turns quantized value from #encodeLongitude back into a double.
[中]将量化值从#encodeLongitude变回double。
代码示例来源:origin: org.apache.lucene/lucene-core
/**
* Turns quantized value from byte array back into a double.
* @param src byte array containing 4 bytes to decode at {@code offset}
* @param offset offset into {@code src} to decode from.
* @return decoded longitude value.
*/
public static double decodeLongitude(byte[] src, int offset) {
return decodeLongitude(NumericUtils.sortableBytesToInt(src, offset));
}
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
protected String toString(int dimension, byte[] value) {
if (dimension == 0) {
return Double.toString(decodeLatitude(value, 0));
} else if (dimension == 1) {
return Double.toString(decodeLongitude(value, 0));
} else {
throw new AssertionError();
}
}
};
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public String toString() {
StringBuilder result = new StringBuilder();
result.append(getClass().getSimpleName());
result.append(" <");
result.append(name);
result.append(':');
long currentValue = (Long)fieldsData;
result.append(decodeLatitude((int)(currentValue >> 32)));
result.append(',');
result.append(decodeLongitude((int)(currentValue & 0xFFFFFFFF)));
result.append('>');
return result.toString();
}
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public String toString(String field) {
StringBuilder sb = new StringBuilder();
if (!this.field.equals(field)) {
sb.append(this.field);
sb.append(':');
}
sb.append("box(minLat=").append(GeoEncodingUtils.decodeLatitude(minLatitude));
sb.append(", maxLat=").append(GeoEncodingUtils.decodeLatitude(maxLatitude));
sb.append(", minLon=").append(GeoEncodingUtils.decodeLongitude(minLongitude));
sb.append(", maxLon=").append(GeoEncodingUtils.decodeLongitude(maxLongitude));
return sb.append(")").toString();
}
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public String toString() {
StringBuilder result = new StringBuilder();
result.append(getClass().getSimpleName());
result.append(" <");
result.append(name);
result.append(':');
byte bytes[] = ((BytesRef) fieldsData).bytes;
result.append(decodeLatitude(bytes, 0));
result.append(',');
result.append(decodeLongitude(bytes, Integer.BYTES));
result.append('>');
return result.toString();
}
代码示例来源:origin: org.apache.lucene/lucene-core
double docLongitude = decodeLongitude(longitudeBits);
cmp = Math.max(cmp, Double.compare(bottom, SloppyMath.haversinSortKey(latitude, longitude, docLatitude, docLongitude)));
代码示例来源:origin: org.apache.lucene/lucene-core
double sortKey(int doc) throws IOException {
if (doc > currentDocs.docID()) {
currentDocs.advance(doc);
}
double minValue = Double.POSITIVE_INFINITY;
if (doc == currentDocs.docID()) {
setValues();
int numValues = currentDocs.docValueCount();
for (int i = 0; i < numValues; i++) {
long encoded = currentValues[i];
double docLatitude = decodeLatitude((int)(encoded >> 32));
double docLongitude = decodeLongitude((int)(encoded & 0xFFFFFFFF));
minValue = Math.min(minValue, SloppyMath.haversinSortKey(latitude, longitude, docLatitude, docLongitude));
}
}
return minValue;
}
代码示例来源:origin: org.apache.lucene/lucene-core
/** Check whether the given point is within the considered polygon.
* NOTE: this operates directly on the encoded representation of points. */
public boolean test(int lat, int lon) {
final int lat2 = ((lat - Integer.MIN_VALUE) >>> latShift);
if (lat2 < latBase || lat2 >= latBase + maxLatDelta) {
return false;
}
int lon2 = ((lon - Integer.MIN_VALUE) >>> lonShift);
if (lon2 < lonBase) { // wrap
lon2 += 1 << (32 - lonShift);
}
assert Integer.toUnsignedLong(lon2) >= lonBase;
assert lon2 - lonBase >= 0;
if (lon2 - lonBase >= maxLonDelta) {
return false;
}
final int relation = relations[(lat2 - latBase) * maxLonDelta + (lon2 - lonBase)];
if (relation == Relation.CELL_CROSSES_QUERY.ordinal()) {
return tree.contains(decodeLatitude(lat), decodeLongitude(lon));
} else {
return relation == Relation.CELL_INSIDE_QUERY.ordinal();
}
}
}
代码示例来源:origin: org.apache.lucene/lucene-core
/** Check whether the given point is within a distance of another point.
* NOTE: this operates directly on the encoded representation of points. */
public boolean test(int lat, int lon) {
final int lat2 = ((lat - Integer.MIN_VALUE) >>> latShift);
if (lat2 < latBase || lat2 >= latBase + maxLatDelta) {
return false;
}
int lon2 = ((lon - Integer.MIN_VALUE) >>> lonShift);
if (lon2 < lonBase) { // wrap
lon2 += 1 << (32 - lonShift);
}
assert Integer.toUnsignedLong(lon2) >= lonBase;
assert lon2 - lonBase >= 0;
if (lon2 - lonBase >= maxLonDelta) {
return false;
}
final int relation = relations[(lat2 - latBase) * maxLonDelta + (lon2 - lonBase)];
if (relation == Relation.CELL_CROSSES_QUERY.ordinal()) {
return SloppyMath.haversinSortKey(
decodeLatitude(lat), decodeLongitude(lon),
this.lat, this.lon) <= distanceKey;
} else {
return relation == Relation.CELL_INSIDE_QUERY.ordinal();
}
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
public static double decodeLongitude(long encodedLatLon) {
return GeoEncodingUtils.decodeLongitude((int) (encodedLatLon & 0xFFFFFFFFL));
}
代码示例来源:origin: org.apache.lucene/lucene-core
decodeLongitude(boxMinLon), decodeLongitude(boxMaxLon))).ordinal();
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append("Rectangle(lat=");
sb.append(decodeLatitude(minY));
sb.append(" TO ");
sb.append(decodeLatitude(maxY));
sb.append(" lon=");
sb.append(decodeLongitude(minX));
sb.append(" TO ");
sb.append(decodeLongitude(maxX));
if (maxX < minX) {
sb.append(" [crosses dateline!]");
}
sb.append(")");
return sb.toString();
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
protected boolean queryMatches(byte[] t, int[] scratchTriangle) {
XLatLonShape.decodeTriangle(t, scratchTriangle);
double alat = GeoEncodingUtils.decodeLatitude(scratchTriangle[0]);
double alon = GeoEncodingUtils.decodeLongitude(scratchTriangle[1]);
double blat = GeoEncodingUtils.decodeLatitude(scratchTriangle[2]);
double blon = GeoEncodingUtils.decodeLongitude(scratchTriangle[3]);
double clat = GeoEncodingUtils.decodeLatitude(scratchTriangle[4]);
double clon = GeoEncodingUtils.decodeLongitude(scratchTriangle[5]);
if (queryRelation == QueryRelation.WITHIN) {
return poly2D.relateTriangle(alon, alat, blon, blat, clon, clat) == Relation.CELL_INSIDE_QUERY;
}
// INTERSECTS
return poly2D.relateTriangle(alon, alat, blon, blat, clon, clat) != Relation.CELL_OUTSIDE_QUERY;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
protected boolean queryMatches(byte[] t, int[] scratchTriangle) {
XLatLonShape.decodeTriangle(t, scratchTriangle);
double alat = GeoEncodingUtils.decodeLatitude(scratchTriangle[0]);
double alon = GeoEncodingUtils.decodeLongitude(scratchTriangle[1]);
double blat = GeoEncodingUtils.decodeLatitude(scratchTriangle[2]);
double blon = GeoEncodingUtils.decodeLongitude(scratchTriangle[3]);
double clat = GeoEncodingUtils.decodeLatitude(scratchTriangle[4]);
double clon = GeoEncodingUtils.decodeLongitude(scratchTriangle[5]);
if (queryRelation == XLatLonShape.QueryRelation.WITHIN) {
return line2D.relateTriangle(alon, alat, blon, blat, clon, clat) == Relation.CELL_INSIDE_QUERY;
}
// INTERSECTS
return line2D.relateTriangle(alon, alat, blon, blat, clon, clat) != Relation.CELL_OUTSIDE_QUERY;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public GeoPoint nextValue() throws IOException {
final long encoded = numericValues.nextValue();
point.reset(GeoEncodingUtils.decodeLatitude((int) (encoded >>> 32)),
GeoEncodingUtils.decodeLongitude((int) encoded));
return point;
}
};
代码示例来源:origin: org.elasticsearch/elasticsearch
public GeoPoint resetFromIndexableField(IndexableField field) {
if (field instanceof LatLonPoint) {
BytesRef br = field.binaryValue();
byte[] bytes = Arrays.copyOfRange(br.bytes, br.offset, br.length);
return this.reset(
GeoEncodingUtils.decodeLatitude(bytes, 0),
GeoEncodingUtils.decodeLongitude(bytes, Integer.BYTES));
} else if (field instanceof LatLonDocValuesField) {
long encoded = (long)(field.numericValue());
return this.reset(
GeoEncodingUtils.decodeLatitude((int)(encoded >>> 32)),
GeoEncodingUtils.decodeLongitude((int)encoded));
}
return resetFromIndexHash(Long.parseLong(field.stringValue()));
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
protected Relation relateRangeBBoxToQuery(int minXOffset, int minYOffset, byte[] minTriangle,
int maxXOffset, int maxYOffset, byte[] maxTriangle) {
double minLat = GeoEncodingUtils.decodeLatitude(NumericUtils.sortableBytesToInt(minTriangle, minYOffset));
double minLon = GeoEncodingUtils.decodeLongitude(NumericUtils.sortableBytesToInt(minTriangle, minXOffset));
double maxLat = GeoEncodingUtils.decodeLatitude(NumericUtils.sortableBytesToInt(maxTriangle, maxYOffset));
double maxLon = GeoEncodingUtils.decodeLongitude(NumericUtils.sortableBytesToInt(maxTriangle, maxXOffset));
// check internal node against query
return line2D.relate(minLat, maxLat, minLon, maxLon);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
protected Relation relateRangeBBoxToQuery(int minXOffset, int minYOffset, byte[] minTriangle,
int maxXOffset, int maxYOffset, byte[] maxTriangle) {
double minLat = GeoEncodingUtils.decodeLatitude(NumericUtils.sortableBytesToInt(minTriangle, minYOffset));
double minLon = GeoEncodingUtils.decodeLongitude(NumericUtils.sortableBytesToInt(minTriangle, minXOffset));
double maxLat = GeoEncodingUtils.decodeLatitude(NumericUtils.sortableBytesToInt(maxTriangle, maxYOffset));
double maxLon = GeoEncodingUtils.decodeLongitude(NumericUtils.sortableBytesToInt(maxTriangle, maxXOffset));
// check internal node against query
return poly2D.relate(minLat, maxLat, minLon, maxLon);
}
代码示例来源:origin: org.apache.lucene/lucene-sandbox
private static double approxBestDistance(byte[] minPackedValue, byte[] maxPackedValue, double pointLat, double pointLon) {
double minLat = decodeLatitude(minPackedValue, 0);
double minLon = decodeLongitude(minPackedValue, Integer.BYTES);
double maxLat = decodeLatitude(maxPackedValue, 0);
double maxLon = decodeLongitude(maxPackedValue, Integer.BYTES);
return approxBestDistance(minLat, maxLat, minLon, maxLon, pointLat, pointLon);
}
代码示例来源:origin: org.apache.lucene/lucene-sandbox
@Override
protected Relation relateRangeBBoxToQuery(int minXOffset, int minYOffset, byte[] minTriangle,
int maxXOffset, int maxYOffset, byte[] maxTriangle) {
double minLat = GeoEncodingUtils.decodeLatitude(LatLonShape.decodeTriangleBoxVal(minTriangle, minYOffset));
double minLon = GeoEncodingUtils.decodeLongitude(LatLonShape.decodeTriangleBoxVal(minTriangle, minXOffset));
double maxLat = GeoEncodingUtils.decodeLatitude(LatLonShape.decodeTriangleBoxVal(maxTriangle, maxYOffset));
double maxLon = GeoEncodingUtils.decodeLongitude(LatLonShape.decodeTriangleBoxVal(maxTriangle, maxXOffset));
// check internal node against query
return line2D.relate(minLat, maxLat, minLon, maxLon);
}
内容来源于网络,如有侵权,请联系作者删除!