org.apache.lucene.geo.GeoEncodingUtils类的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(11.1k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中org.apache.lucene.geo.GeoEncodingUtils类的一些代码示例,展示了GeoEncodingUtils类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GeoEncodingUtils类的具体详情如下:
包路径:org.apache.lucene.geo.GeoEncodingUtils
类名称:GeoEncodingUtils

GeoEncodingUtils介绍

[英]reusable geopoint encoding methods
[中]可重用的地质点编码方法

代码示例

代码示例来源: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

private static Grid createSubBoxes(Rectangle boundingBox, Function<Rectangle, Relation> boxToRelation) {
 final int minLat = encodeLatitudeCeil(boundingBox.minLat);
 final int maxLat = encodeLatitude(boundingBox.maxLat);
 final int minLon = encodeLongitudeCeil(boundingBox.minLon);
 final int maxLon = encodeLongitude(boundingBox.maxLon);
  latShift = computeShift(minLat2, maxLat2);
  latBase = (int) (minLat2 >>> latShift);
  maxLatDelta = (int) (maxLat2 >>> latShift) - latBase + 1;
   maxLon2 += 1L << 32; // wrap
  lonShift = computeShift(minLon2, maxLon2);
  lonBase = (int) (minLon2 >>> lonShift);
  maxLonDelta = (int) (maxLon2 >>> lonShift) - lonBase + 1;
     decodeLatitude(boxMinLat), decodeLatitude(boxMaxLat),
     decodeLongitude(boxMinLon), decodeLongitude(boxMaxLon))).ordinal();

代码示例来源:origin: org.apache.lucene/lucene-core

/**
 * Change the values of this field
 * @param latitude latitude value: must be within standard +/-90 coordinate bounds.
 * @param longitude longitude value: must be within standard +/-180 coordinate bounds.
 * @throws IllegalArgumentException if latitude or longitude are out of bounds
 */
public void setLocationValue(double latitude, double longitude) {
 int latitudeEncoded = encodeLatitude(latitude);
 int longitudeEncoded = encodeLongitude(longitude);
 fieldsData = Long.valueOf((((long)latitudeEncoded) << 32) | (longitudeEncoded & 0xFFFFFFFFL));
}

代码示例来源:origin: org.apache.lucene/lucene-core

/** sugar encodes a single point as a byte array, rounding values up */
private static byte[] encodeCeil(double latitude, double longitude) {
 byte[] bytes = new byte[2 * Integer.BYTES];
 NumericUtils.intToSortableBytes(encodeLatitudeCeil(latitude), bytes, 0);
 NumericUtils.intToSortableBytes(encodeLongitudeCeil(longitude), bytes, Integer.BYTES);
 return bytes;
}

代码示例来源:origin: org.apache.lucene/lucene-core

LatLonDocValuesBoxQuery(String field, double minLatitude, double maxLatitude, double minLongitude, double maxLongitude) {
 GeoUtils.checkLatitude(minLatitude);
 GeoUtils.checkLatitude(maxLatitude);
 GeoUtils.checkLongitude(minLongitude);
 GeoUtils.checkLongitude(maxLongitude);
 if (field == null) {
  throw new IllegalArgumentException("field must not be null");
 }
 this.field = field;
 this.crossesDateline = minLongitude > maxLongitude; // make sure to compute this before rounding
 this.minLatitude = GeoEncodingUtils.encodeLatitudeCeil(minLatitude);
 this.maxLatitude = GeoEncodingUtils.encodeLatitude(maxLatitude);
 this.minLongitude = GeoEncodingUtils.encodeLongitudeCeil(minLongitude);
 this.maxLongitude = GeoEncodingUtils.encodeLongitude(maxLongitude);
}

代码示例来源: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

/**
 * 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 latitude value.
 */
public static double decodeLatitude(byte[] src, int offset) {
 return decodeLatitude(NumericUtils.sortableBytesToInt(src, offset));
}

代码示例来源:origin: org.apache.lucene/lucene-core

final byte minLon[] = new byte[Integer.BYTES];
final byte maxLon[] = new byte[Integer.BYTES];
NumericUtils.intToSortableBytes(encodeLatitude(box.minLat), minLat, 0);
NumericUtils.intToSortableBytes(encodeLatitude(box.maxLat), maxLat, 0);
NumericUtils.intToSortableBytes(encodeLongitude(box.minLon), minLon, 0);
NumericUtils.intToSortableBytes(encodeLongitude(box.maxLon), maxLon, 0);
final GeoEncodingUtils.PolygonPredicate polygonPredicate = GeoEncodingUtils.createPolygonPredicate(polygons, tree);

代码示例来源:origin: org.apache.lucene/lucene-core

NumericUtils.intToSortableBytes(encodeLatitude(box.minLat), minLat, 0);
NumericUtils.intToSortableBytes(encodeLatitude(box.maxLat), maxLat, 0);
 NumericUtils.intToSortableBytes(encodeLongitude(box.maxLon), maxLon, 0);
 NumericUtils.intToSortableBytes(encodeLongitude(box.minLon), minLon2, 0);
} else {
 NumericUtils.intToSortableBytes(encodeLongitude(box.minLon), minLon, 0);
 NumericUtils.intToSortableBytes(encodeLongitude(box.maxLon), maxLon, 0);
 final GeoEncodingUtils.DistancePredicate distancePredicate = GeoEncodingUtils.createDistancePredicate(latitude, longitude, radiusMeters);

代码示例来源:origin: org.apache.lucene/lucene-core

/** sugar encodes a single point as a byte array */
private static byte[] encode(double latitude, double longitude) {
 byte[] bytes = new byte[2 * Integer.BYTES];
 NumericUtils.intToSortableBytes(encodeLatitude(latitude), bytes, 0);
 NumericUtils.intToSortableBytes(encodeLongitude(longitude), bytes, Integer.BYTES);
 return bytes;
}

代码示例来源:origin: org.elasticsearch/elasticsearch

private XRectangle2D(double minLat, double maxLat, double minLon, double maxLon) {
 this.bbox = new byte[4 * BYTES];
 int minXenc = encodeLongitudeCeil(minLon);
 int maxXenc = encodeLongitude(maxLon);
 int minYenc = encodeLatitudeCeil(minLat);
 int maxYenc = encodeLatitude(maxLat);
 if (minYenc > maxYenc) {
  minYenc = maxYenc;
 }
 this.minY = minYenc;
 this.maxY = maxYenc;
 if (minLon > maxLon == true) {
  // crossing dateline is split into east/west boxes
  this.west = new byte[4 * BYTES];
  this.minX = minXenc;
  this.maxX = maxXenc;
  encode(MIN_LON_ENCODED, this.maxX, this.minY, this.maxY, this.west);
  encode(this.minX, MAX_LON_ENCODED, this.minY, this.maxY, this.bbox);
 } else {
  // encodeLongitudeCeil may cause minX to be > maxX iff
  // the delta between the longitude < the encoding resolution
  if (minXenc > maxXenc) {
   minXenc = maxXenc;
  }
  this.west = null;
  this.minX = minXenc;
  this.maxX = maxXenc;
  encode(this.minX, this.maxX, this.minY, this.maxY, bbox);
 }
}

代码示例来源:origin: org.elasticsearch/elasticsearch

public static double decodeLongitude(long encodedLatLon) {
  return GeoEncodingUtils.decodeLongitude((int) (encodedLatLon & 0xFFFFFFFFL));
}

代码示例来源:origin: org.elasticsearch/elasticsearch

public static double decodeLatitude(long encodedLatLon) {
  return GeoEncodingUtils.decodeLatitude((int) (encodedLatLon >>> 32));
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

final byte minLon[] = new byte[Integer.BYTES];
final byte maxLon[] = new byte[Integer.BYTES];
NumericUtils.intToSortableBytes(encodeLatitude(box.minLat), minLat, 0);
NumericUtils.intToSortableBytes(encodeLatitude(box.maxLat), maxLat, 0);
NumericUtils.intToSortableBytes(encodeLongitude(box.minLon), minLon, 0);
NumericUtils.intToSortableBytes(encodeLongitude(box.maxLon), maxLon, 0);
final GeoEncodingUtils.PolygonPredicate polygonPredicate = GeoEncodingUtils.createPolygonPredicate(polygons, tree);

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

NumericUtils.intToSortableBytes(encodeLatitude(box.minLat), minLat, 0);
NumericUtils.intToSortableBytes(encodeLatitude(box.maxLat), maxLat, 0);
 NumericUtils.intToSortableBytes(encodeLongitude(box.maxLon), maxLon, 0);
 NumericUtils.intToSortableBytes(encodeLongitude(box.minLon), minLon2, 0);
} else {
 NumericUtils.intToSortableBytes(encodeLongitude(box.minLon), minLon, 0);
 NumericUtils.intToSortableBytes(encodeLongitude(box.maxLon), maxLon, 0);
 final GeoEncodingUtils.DistancePredicate distancePredicate = GeoEncodingUtils.createDistancePredicate(latitude, longitude, radiusMeters);

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

/** sugar encodes a single point as a byte array, rounding values up */
private static byte[] encodeCeil(double latitude, double longitude) {
 byte[] bytes = new byte[2 * Integer.BYTES];
 NumericUtils.intToSortableBytes(encodeLatitudeCeil(latitude), bytes, 0);
 NumericUtils.intToSortableBytes(encodeLongitudeCeil(longitude), bytes, Integer.BYTES);
 return bytes;
}

代码示例来源: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.servicemix.bundles/org.apache.servicemix.bundles.lucene

private static Grid createSubBoxes(Rectangle boundingBox, Function<Rectangle, Relation> boxToRelation) {
 final int minLat = encodeLatitudeCeil(boundingBox.minLat);
 final int maxLat = encodeLatitude(boundingBox.maxLat);
 final int minLon = encodeLongitudeCeil(boundingBox.minLon);
 final int maxLon = encodeLongitude(boundingBox.maxLon);
  latShift = computeShift(minLat2, maxLat2);
  latBase = (int) (minLat2 >>> latShift);
  maxLatDelta = (int) (maxLat2 >>> latShift) - latBase + 1;
   maxLon2 += 1L << 32; // wrap
  lonShift = computeShift(minLon2, maxLon2);
  lonBase = (int) (minLon2 >>> lonShift);
  maxLonDelta = (int) (maxLon2 >>> lonShift) - lonBase + 1;
     decodeLatitude(boxMinLat), decodeLatitude(boxMaxLat),
     decodeLongitude(boxMinLon), decodeLongitude(boxMaxLon))).ordinal();

代码示例来源:origin: org.apache.lucene/lucene-core

@Override
public void setBottom(int slot) {
 bottom = values[slot];
 // make bounding box(es) to exclude non-competitive hits, but start
 // sampling if we get called way too much: don't make gobs of bounding
 // boxes if comparator hits a worst case order (e.g. backwards distance order)
 if (setBottomCounter < 1024 || (setBottomCounter & 0x3F) == 0x3F) {
  Rectangle box = Rectangle.fromPointDistance(latitude, longitude, haversin2(bottom));
  // pre-encode our box to our integer encoding, so we don't have to decode 
  // to double values for uncompetitive hits. This has some cost!
  minLat = encodeLatitude(box.minLat);
  maxLat = encodeLatitude(box.maxLat);
  if (box.crossesDateline()) {
   // box1
   minLon = Integer.MIN_VALUE;
   maxLon = encodeLongitude(box.maxLon);
   // box2
   minLon2 = encodeLongitude(box.minLon);
  } else {
   minLon = encodeLongitude(box.minLon);
   maxLon = encodeLongitude(box.maxLon);
   // disable box2
   minLon2 = Integer.MAX_VALUE;
  }
 }
 setBottomCounter++;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

LatLonDocValuesBoxQuery(String field, double minLatitude, double maxLatitude, double minLongitude, double maxLongitude) {
 GeoUtils.checkLatitude(minLatitude);
 GeoUtils.checkLatitude(maxLatitude);
 GeoUtils.checkLongitude(minLongitude);
 GeoUtils.checkLongitude(maxLongitude);
 if (field == null) {
  throw new IllegalArgumentException("field must not be null");
 }
 this.field = field;
 this.crossesDateline = minLongitude > maxLongitude; // make sure to compute this before rounding
 this.minLatitude = GeoEncodingUtils.encodeLatitudeCeil(minLatitude);
 this.maxLatitude = GeoEncodingUtils.encodeLatitude(maxLatitude);
 this.minLongitude = GeoEncodingUtils.encodeLongitudeCeil(minLongitude);
 this.maxLongitude = GeoEncodingUtils.encodeLongitude(maxLongitude);
}

相关文章