本文整理汇总了Java中org.elasticsearch.common.geo.GeoPoint.lat方法的典型用法代码示例。如果您正苦于以下问题:Java GeoPoint.lat方法的具体用法?Java GeoPoint.lat怎么用?Java GeoPoint.lat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.common.geo.GeoPoint
的用法示例。
在下文中一共展示了GeoPoint.lat方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.elasticsearch.common.geo.GeoPoint; //导入方法依赖的package包/类
@Override
protected void parse(ParseContext context, GeoPoint point, String geoHash) throws IOException {
if (ignoreMalformed.value() == false) {
if (point.lat() > 90.0 || point.lat() < -90.0) {
throw new IllegalArgumentException("illegal latitude value [" + point.lat() + "] for " + name());
}
if (point.lon() > 180.0 || point.lon() < -180) {
throw new IllegalArgumentException("illegal longitude value [" + point.lon() + "] for " + name());
}
} else {
// LUCENE WATCH: This will be folded back into Lucene's GeoPointField
GeoUtils.normalizePoint(point);
}
if (fieldType().indexOptions() != IndexOptions.NONE || fieldType().stored()) {
context.doc().add(new GeoPointField(fieldType().names().indexName(), point.lon(), point.lat(), fieldType() ));
}
super.parse(context, point, geoHash);
}
示例2: parse
import org.elasticsearch.common.geo.GeoPoint; //导入方法依赖的package包/类
protected void parse(ParseContext originalContext, GeoPoint point) throws IOException {
// Geopoint fields, by default, will not be included in _all
final ParseContext context = originalContext.setIncludeInAllDefault(false);
if (ignoreMalformed.value() == false) {
if (point.lat() > 90.0 || point.lat() < -90.0) {
throw new IllegalArgumentException("illegal latitude value [" + point.lat() + "] for " + name());
}
if (point.lon() > 180.0 || point.lon() < -180) {
throw new IllegalArgumentException("illegal longitude value [" + point.lon() + "] for " + name());
}
} else {
GeoUtils.normalizePoint(point);
}
if (fieldType().indexOptions() != IndexOptions.NONE) {
context.doc().add(new LatLonPoint(fieldType().name(), point.lat(), point.lon()));
}
if (fieldType().stored()) {
context.doc().add(new StoredField(fieldType().name(), point.toString()));
}
if (fieldType.hasDocValues()) {
context.doc().add(new LatLonDocValuesField(fieldType().name(), point.lat(), point.lon()));
}
// if the mapping contains multifields then use the geohash string
if (multiFields.iterator().hasNext()) {
multiFields.parse(this, context.createExternalValueContext(point.geohash()));
}
}
示例3: updateHashCentroid
import org.elasticsearch.common.geo.GeoPoint; //导入方法依赖的package包/类
private GeoPoint updateHashCentroid(String hash, final GeoPoint location) {
GeoPoint centroid = expectedCentroidsForGeoHash.getOrDefault(hash, null);
if (centroid == null) {
return new GeoPoint(location.lat(), location.lon());
}
final int docCount = expectedDocCountsForGeoHash.get(hash);
final double newLon = centroid.lon() + (location.lon() - centroid.lon()) / docCount;
final double newLat = centroid.lat() + (location.lat() - centroid.lat()) / docCount;
return centroid.reset(newLat, newLon);
}
示例4: updateBoundsBottomRight
import org.elasticsearch.common.geo.GeoPoint; //导入方法依赖的package包/类
private void updateBoundsBottomRight(GeoPoint geoPoint, GeoPoint currentBound) {
if (geoPoint.lat() < currentBound.lat()) {
currentBound.resetLat(geoPoint.lat());
}
if (geoPoint.lon() > currentBound.lon()) {
currentBound.resetLon(geoPoint.lon());
}
}
示例5: updateBoundsTopLeft
import org.elasticsearch.common.geo.GeoPoint; //导入方法依赖的package包/类
private void updateBoundsTopLeft(GeoPoint geoPoint, GeoPoint currentBound) {
if (geoPoint.lat() > currentBound.lat()) {
currentBound.resetLat(geoPoint.lat());
}
if (geoPoint.lon() < currentBound.lon()) {
currentBound.resetLon(geoPoint.lon());
}
}
示例6: testEqualsHashCodeContract
import org.elasticsearch.common.geo.GeoPoint; //导入方法依赖的package包/类
public void testEqualsHashCodeContract() {
// generate a random geopoint
final GeoPoint x = RandomGeoGenerator.randomPoint(random());
final GeoPoint y = new GeoPoint(x.lat(), x.lon());
final GeoPoint z = new GeoPoint(y.lat(), y.lon());
// GeoPoint doesn't care about coordinate system bounds, this simply validates inequality
final GeoPoint a = new GeoPoint(x.lat() + randomIntBetween(1, 5), x.lon() + randomIntBetween(1, 5));
/** equality test */
// reflexive
assertTrue(x.equals(x));
// symmetry
assertTrue(x.equals(y));
// transitivity
assertTrue(y.equals(z));
assertTrue(x.equals(z));
// inequality
assertFalse(x.equals(a));
/** hashCode test */
// symmetry
assertTrue(x.hashCode() == y.hashCode());
// transitivity
assertTrue(y.hashCode() == z.hashCode());
assertTrue(x.hashCode() == z.hashCode());
// inequality
assertFalse(x.hashCode() == a.hashCode());
}
示例7: value
import org.elasticsearch.common.geo.GeoPoint; //导入方法依赖的package包/类
@Override
public Double[] value() {
switch (values.count()) {
case 0:
return null;
case 1:
GeoPoint gp = values.valueAt(0);
return new Double[] { gp.lon(), gp.lat() };
default:
throw new GroupByOnArrayUnsupportedException(columnName());
}
}
示例8: getLeafCollector
import org.elasticsearch.common.geo.GeoPoint; //导入方法依赖的package包/类
@Override
public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, LeafBucketCollector sub) throws IOException {
if (valuesSource == null) {
return LeafBucketCollector.NO_OP_COLLECTOR;
}
final BigArrays bigArrays = context.bigArrays();
final MultiGeoPointValues values = valuesSource.geoPointValues(ctx);
return new LeafBucketCollectorBase(sub, values) {
@Override
public void collect(int doc, long bucket) throws IOException {
centroids = bigArrays.grow(centroids, bucket + 1);
counts = bigArrays.grow(counts, bucket + 1);
values.setDocument(doc);
final int valueCount = values.count();
if (valueCount > 0) {
double[] pt = new double[2];
// get the previously accumulated number of counts
long prevCounts = counts.get(bucket);
// increment by the number of points for this document
counts.increment(bucket, valueCount);
// get the previous GeoPoint if a moving avg was computed
if (prevCounts > 0) {
final GeoPoint centroid = GeoPoint.fromIndexLong(centroids.get(bucket));
pt[0] = centroid.lon();
pt[1] = centroid.lat();
}
// update the moving average
for (int i = 0; i < valueCount; ++i) {
GeoPoint value = values.valueAt(i);
pt[0] = pt[0] + (value.getLon() - pt[0]) / ++prevCounts;
pt[1] = pt[1] + (value.getLat() - pt[1]) / prevCounts;
}
centroids.set(bucket, GeoEncodingUtils.mortonHash(pt[0], pt[1]));
}
}
};
}
示例9: get
import org.elasticsearch.common.geo.GeoPoint; //导入方法依赖的package包/类
@Override
public boolean get(int doc) {
values.setDocument(doc);
final int length = values.count();
for (int i = 0; i < length; i++) {
GeoPoint point = values.valueAt(i);
if (((topLeft.lon() <= point.lon() || bottomRight.lon() >= point.lon())) &&
(topLeft.lat() >= point.lat() && bottomRight.lat() <= point.lat())) {
return true;
}
}
return false;
}
示例10: getLeafCollector
import org.elasticsearch.common.geo.GeoPoint; //导入方法依赖的package包/类
@Override
public LeafBucketCollector getLeafCollector(LeafReaderContext ctx,
LeafBucketCollector sub) {
if (valuesSource == null) {
return LeafBucketCollector.NO_OP_COLLECTOR;
}
final BigArrays bigArrays = context.bigArrays();
final MultiGeoPointValues values = valuesSource.geoPointValues(ctx);
return new LeafBucketCollectorBase(sub, values) {
@Override
public void collect(int doc, long bucket) throws IOException {
if (bucket >= tops.size()) {
long from = tops.size();
tops = bigArrays.grow(tops, bucket + 1);
tops.fill(from, tops.size(), Double.NEGATIVE_INFINITY);
bottoms = bigArrays.resize(bottoms, tops.size());
bottoms.fill(from, bottoms.size(), Double.POSITIVE_INFINITY);
posLefts = bigArrays.resize(posLefts, tops.size());
posLefts.fill(from, posLefts.size(), Double.POSITIVE_INFINITY);
posRights = bigArrays.resize(posRights, tops.size());
posRights.fill(from, posRights.size(), Double.NEGATIVE_INFINITY);
negLefts = bigArrays.resize(negLefts, tops.size());
negLefts.fill(from, negLefts.size(), Double.POSITIVE_INFINITY);
negRights = bigArrays.resize(negRights, tops.size());
negRights.fill(from, negRights.size(), Double.NEGATIVE_INFINITY);
}
values.setDocument(doc);
final int valuesCount = values.count();
for (int i = 0; i < valuesCount; ++i) {
GeoPoint value = values.valueAt(i);
double top = tops.get(bucket);
if (value.lat() > top) {
top = value.lat();
}
double bottom = bottoms.get(bucket);
if (value.lat() < bottom) {
bottom = value.lat();
}
double posLeft = posLefts.get(bucket);
if (value.lon() >= 0 && value.lon() < posLeft) {
posLeft = value.lon();
}
double posRight = posRights.get(bucket);
if (value.lon() >= 0 && value.lon() > posRight) {
posRight = value.lon();
}
double negLeft = negLefts.get(bucket);
if (value.lon() < 0 && value.lon() < negLeft) {
negLeft = value.lon();
}
double negRight = negRights.get(bucket);
if (value.lon() < 0 && value.lon() > negRight) {
negRight = value.lon();
}
tops.set(bucket, top);
bottoms.set(bucket, bottom);
posLefts.set(bucket, posLeft);
posRights.set(bucket, posRight);
negLefts.set(bucket, negLeft);
negRights.set(bucket, negRight);
}
}
};
}
示例11: get
import org.elasticsearch.common.geo.GeoPoint; //导入方法依赖的package包/类
@Override
public GeoPoint get(int index) {
final GeoPoint point = values.valueAt(index);
return new GeoPoint(point.lat(), point.lon());
}
示例12: randomGeoPointField
import org.elasticsearch.common.geo.GeoPoint; //导入方法依赖的package包/类
protected Field randomGeoPointField(String fieldName, Field.Store store) {
GeoPoint point = randomPoint(random());
return new LatLonDocValuesField(fieldName, point.lat(), point.lon());
}