Java Code Examples for org.apache.lucene.spatial.query.SpatialArgs#calcDistanceFromErrPct()

The following examples show how to use org.apache.lucene.spatial.query.SpatialArgs#calcDistanceFromErrPct() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RandomSpatialOpFuzzyPrefixTreeTest.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
protected Shape gridSnap(Shape snapMe) {
  if (snapMe == null)
    return null;
  if (snapMe instanceof ShapePair) {
    ShapePair me = (ShapePair) snapMe;
    return new ShapePair(gridSnap(me.shape1), gridSnap(me.shape2), me.biasContainsThenWithin);
  }
  if (snapMe instanceof Point) {
    snapMe = snapMe.getBoundingBox();
  }
  //The next 4 lines mimic PrefixTreeStrategy.createIndexableFields()
  double distErrPct = ((PrefixTreeStrategy) strategy).getDistErrPct();
  double distErr = SpatialArgs.calcDistanceFromErrPct(snapMe, distErrPct, ctx);
  int detailLevel = grid.getLevelForDistance(distErr);
  CellIterator cells = grid.getTreeCellIterator(snapMe, detailLevel);

  //calc bounding box of cells.
  List<Shape> cellShapes = new ArrayList<>(1024);
  while (cells.hasNext()) {
    Cell cell = cells.next();
    if (!cell.isLeaf())
      continue;
    cellShapes.add(cell.getShape());
  }
  return new ShapeCollection<>(cellShapes, ctx).getBoundingBox();
}
 
Example 2
Source File: PrefixTreeStrategy.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public void setShape(Shape shape) {
  double distErr = SpatialArgs.calcDistanceFromErrPct(shape, distErrPct, ctx);
  int detailLevel = grid.getLevelForDistance(distErr);
  Iterator<Cell> cells = createCellIteratorToIndex(shape, detailLevel, null);
  CellToBytesRefIterator cellToBytesRefIterator = newCellToBytesRefIterator();
  cellToBytesRefIterator.reset(cells);
  setBytesRefIterator(cellToBytesRefIterator);
}
 
Example 3
Source File: PrefixTreeStrategy.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
public Field[] createIndexableFields(Shape shape) {
  double distErr = SpatialArgs.calcDistanceFromErrPct(shape, distErrPct, ctx);
  return createIndexableFields(shape, distErr);
}
 
Example 4
Source File: PrefixTreeStrategy.java    From incubator-retired-blur with Apache License 2.0 4 votes vote down vote up
@Override
public Field[] createIndexableFields(Shape shape) {
  double distErr = SpatialArgs.calcDistanceFromErrPct(shape, distErrPct, ctx);
  return createIndexableFields(shape, distErr);
}