Tabnine Logo
Rectangle.fromPointDistance
Code IndexAdd Tabnine to your IDE (free)

How to use
fromPointDistance
method
in
org.apache.lucene.geo.Rectangle

Best Java code snippets using org.apache.lucene.geo.Rectangle.fromPointDistance (Showing top 8 results out of 315)

origin: org.apache.lucene/lucene-core

/** Create a predicate that checks whether points are within a distance of a given point.
 *  It works by computing the bounding box around the circle that is defined
 *  by the given points/distance and splitting it into between 1024 and 4096
 *  smaller boxes (4096*0.75^2=2304 on average). Then for each sub box, it
 *  computes the relation between this box and the distance query. Finally at
 *  search time, it first computes the sub box that the point belongs to,
 *  most of the time, no distance computation will need to be performed since
 *  all points from the sub box will either be in or out of the circle.
 *  @lucene.internal */
public static DistancePredicate createDistancePredicate(double lat, double lon, double radiusMeters) {
 final Rectangle boundingBox = Rectangle.fromPointDistance(lat, lon, radiusMeters);
 final double axisLat = Rectangle.axisLat(lat, radiusMeters);
 final double distanceSortKey = GeoUtils.distanceQuerySortKey(radiusMeters);
 final Function<Rectangle, Relation> boxToRelation = box -> GeoUtils.relate(
   box.minLat, box.maxLat, box.minLon, box.maxLon, lat, lon, distanceSortKey, axisLat);
 final Grid subBoxes = createSubBoxes(boundingBox, boxToRelation);
 return new DistancePredicate(
   subBoxes.latShift, subBoxes.lonShift,
   subBoxes.latBase, subBoxes.lonBase,
   subBoxes.maxLatDelta, subBoxes.maxLonDelta,
   subBoxes.relations,
   lat, lon, distanceSortKey);
}
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.lucene/lucene-core

@Override
public Weight createWeight(IndexSearcher searcher, boolean needsScores, float boost) throws IOException {
 Rectangle box = Rectangle.fromPointDistance(latitude, longitude, radiusMeters);
origin: org.apache.lucene/lucene-sandbox

private void maybeUpdateBBox() {
 if (setBottomCounter < 1024 || (setBottomCounter & 0x3F) == 0x3F) {
  NearestHit hit = hitQueue.peek();
  Rectangle box = Rectangle.fromPointDistance(pointLat, pointLon, hit.distanceMeters);
  //System.out.println("    update bbox to " + box);
  minLat = box.minLat;
  maxLat = box.maxLat;
  if (box.crossesDateline()) {
   // box1
   minLon = Double.NEGATIVE_INFINITY;
   maxLon = box.maxLon;
   // box2
   minLon2 = box.minLon;
  } else {
   minLon = box.minLon;
   maxLon = box.maxLon;
   // disable box2
   minLon2 = Double.POSITIVE_INFINITY;
  }
 }
 setBottomCounter++;
}
origin: com.strapdata.elasticsearch/elasticsearch

bbox = Rectangle.fromPointDistance(lat, lon, inclusiveUpperPoint);
if ("memory".equals(optimizeBbox)) {
  boundingBoxFilter = null;
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

/** Create a predicate that checks whether points are within a distance of a given point.
 *  It works by computing the bounding box around the circle that is defined
 *  by the given points/distance and splitting it into between 1024 and 4096
 *  smaller boxes (4096*0.75^2=2304 on average). Then for each sub box, it
 *  computes the relation between this box and the distance query. Finally at
 *  search time, it first computes the sub box that the point belongs to,
 *  most of the time, no distance computation will need to be performed since
 *  all points from the sub box will either be in or out of the circle.
 *  @lucene.internal */
public static DistancePredicate createDistancePredicate(double lat, double lon, double radiusMeters) {
 final Rectangle boundingBox = Rectangle.fromPointDistance(lat, lon, radiusMeters);
 final double axisLat = Rectangle.axisLat(lat, radiusMeters);
 final double distanceSortKey = GeoUtils.distanceQuerySortKey(radiusMeters);
 final Function<Rectangle, Relation> boxToRelation = box -> GeoUtils.relate(
   box.minLat, box.maxLat, box.minLon, box.maxLon, lat, lon, distanceSortKey, axisLat);
 final Grid subBoxes = createSubBoxes(boundingBox, boxToRelation);
 return new DistancePredicate(
   subBoxes.latShift, subBoxes.lonShift,
   subBoxes.latBase, subBoxes.lonBase,
   subBoxes.maxLatDelta, subBoxes.maxLonDelta,
   subBoxes.relations,
   lat, lon, distanceSortKey);
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

@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

@Override
public Weight createWeight(IndexSearcher searcher, boolean needsScores, float boost) throws IOException {
 Rectangle box = Rectangle.fromPointDistance(latitude, longitude, radiusMeters);
org.apache.lucene.geoRectanglefromPointDistance

Javadoc

Compute Bounding Box for a circle using WGS-84 parameters

Popular methods of Rectangle

  • <init>
    Constructs a bounding box by first validating the provided latitude and longitude coordinates
  • crossesDateline
    Returns true if this bounding box crosses the dateline
  • containsPoint
    returns true if rectangle (defined by minLat, maxLat, minLon, maxLon) contains the lat lon point
  • axisLat
    Calculate the latitude of a circle's intersections with its bbox meridians.NOTE: the returned value
  • fromPolygon
    Returns the bounding box over an array of polygons
  • equals

Popular in Java

  • Making http requests using okhttp
  • getSharedPreferences (Context)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • addToBackStack (FragmentTransaction)
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • JLabel (javax.swing)
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now