List of usage examples for org.apache.lucene.spatial.query UnsupportedSpatialOperation UnsupportedSpatialOperation
public UnsupportedSpatialOperation(SpatialOperation op)
From source file:org.apache.blur.analysis.type.spatial.lucene.RecursivePrefixTreeStrategy.java
License:Apache License
@Override public Filter makeFilter(SpatialArgs args) { final SpatialOperation op = args.getOperation(); if (op == SpatialOperation.IsDisjointTo) return new DisjointSpatialFilter(this, args, getFieldName()); Shape shape = args.getShape(); int detailLevel = grid.getLevelForDistance(args.resolveDistErr(ctx, distErrPct)); final boolean hasIndexedLeaves = true; if (op == SpatialOperation.Intersects) { return new IntersectsPrefixTreeFilter(shape, getFieldName(), grid, detailLevel, prefixGridScanLevel, hasIndexedLeaves);/*from w ww . ja va 2s. c o m*/ } else if (op == SpatialOperation.IsWithin) { return new WithinPrefixTreeFilter(shape, getFieldName(), grid, detailLevel, prefixGridScanLevel, -1);// -1 // flag // is // slower // but // ensures // correct // results } else if (op == SpatialOperation.Contains) { return new ContainsPrefixTreeFilter(shape, getFieldName(), grid, detailLevel); } throw new UnsupportedSpatialOperation(op); }
From source file:org.apache.blur.analysis.type.spatial.lucene.TermQueryPrefixTreeStrategy.java
License:Apache License
@Override public Filter makeFilter(SpatialArgs args) { final SpatialOperation op = args.getOperation(); if (op != SpatialOperation.Intersects) throw new UnsupportedSpatialOperation(op); Shape shape = args.getShape(); int detailLevel = grid.getLevelForDistance(args.resolveDistErr(ctx, distErrPct)); List<Cell> cells = grid.getCells(shape, detailLevel, false, // no parents true);// simplify BytesRef[] terms = new BytesRef[cells.size()]; int i = 0;/* www. j a v a2 s . c o m*/ for (Cell cell : cells) { terms[i++] = new BytesRef(cell.getTokenString()); } return new TermsFilter(getFieldName(), terms); }
From source file:org.apache.solr.legacy.BBoxStrategy.java
License:Apache License
@Override public Query makeQuery(SpatialArgs args) { Shape shape = args.getShape(); if (!(shape instanceof Rectangle)) throw new UnsupportedOperationException("Can only query by Rectangle, not " + shape); Rectangle bbox = (Rectangle) shape; Query spatial;//from w w w . j a v a 2 s. c o m // Useful for understanding Relations: // http://edndoc.esri.com/arcsde/9.1/general_topics/understand_spatial_relations.htm SpatialOperation op = args.getOperation(); if (op == SpatialOperation.BBoxIntersects) spatial = makeIntersects(bbox); else if (op == SpatialOperation.BBoxWithin) spatial = makeWithin(bbox); else if (op == SpatialOperation.Contains) spatial = makeContains(bbox); else if (op == SpatialOperation.Intersects) spatial = makeIntersects(bbox); else if (op == SpatialOperation.IsEqualTo) spatial = makeEquals(bbox); else if (op == SpatialOperation.IsDisjointTo) spatial = makeDisjoint(bbox); else if (op == SpatialOperation.IsWithin) spatial = makeWithin(bbox); else { //no Overlaps support yet throw new UnsupportedSpatialOperation(op); } return new ConstantScoreQuery(spatial); }
From source file:org.apache.solr.legacy.PointVectorStrategy.java
License:Apache License
@Override public ConstantScoreQuery makeQuery(SpatialArgs args) { if (!SpatialOperation.is(args.getOperation(), SpatialOperation.Intersects, SpatialOperation.IsWithin)) throw new UnsupportedSpatialOperation(args.getOperation()); Shape shape = args.getShape(); if (shape instanceof Rectangle) { Rectangle bbox = (Rectangle) shape; return new ConstantScoreQuery(makeWithin(bbox)); } else if (shape instanceof Circle) { Circle circle = (Circle) shape;//from ww w . ja v a 2 s .c o m Rectangle bbox = circle.getBoundingBox(); Query approxQuery = makeWithin(bbox); BooleanQuery.Builder bqBuilder = new BooleanQuery.Builder(); double r = circle.getRadius(); FunctionMatchQuery vsMatchQuery = new FunctionMatchQuery(makeDistanceValueSource(circle.getCenter()), v -> 0 <= v && v <= r); bqBuilder.add(approxQuery, BooleanClause.Occur.FILTER);//should have lowest "cost" value; will drive iteration bqBuilder.add(vsMatchQuery, BooleanClause.Occur.FILTER); return new ConstantScoreQuery(bqBuilder.build()); } else { throw new UnsupportedOperationException( "Only Rectangles and Circles are currently supported, " + "found [" + shape.getClass() + "]");//TODO } }