Example usage for org.apache.lucene.spatial.query SpatialOperation BBoxWithin

List of usage examples for org.apache.lucene.spatial.query SpatialOperation BBoxWithin

Introduction

In this page you can find the example usage for org.apache.lucene.spatial.query SpatialOperation BBoxWithin.

Prototype

SpatialOperation BBoxWithin

To view the source code for org.apache.lucene.spatial.query SpatialOperation BBoxWithin.

Click Source Link

Document

Bounding box of the *indexed* shape, then #IsWithin .

Usage

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 ww  . ja  v  a  2 s. co  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);
}