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

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

Introduction

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

Prototype

SpatialOperation BBoxIntersects

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

Click Source Link

Document

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

Usage

From source file:com.orientechnologies.spatial.operator.OLuceneOverlapOperator.java

License:Apache License

@Override
public Object evaluateRecord(OIdentifiable iRecord, ODocument iCurrentResult, OSQLFilterCondition iCondition,
        Object iLeft, Object iRight, OCommandContext iContext) {
    Shape shape = factory.fromDoc((ODocument) iLeft);

    // TODO { 'shape' : { 'type' : 'LineString' , 'coordinates' : [[1,2],[4,6]]} }
    // TODO is not translated in map but in array[ { 'type' : 'LineString' , 'coordinates' : [[1,2],[4,6]]} ]
    Object filter;//from   w w  w .  j av a2 s .c o  m
    if (iRight instanceof Collection) {
        filter = ((Collection) iRight).iterator().next();
    } else {
        filter = iRight;
    }
    Shape shape1 = factory.fromObject(filter);

    return SpatialOperation.BBoxIntersects.evaluate(shape, shape1.getBoundingBox());
}

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 .ja v  a2s.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);
}