Search in sources :

Example 1 with BBox

use of org.polymap.recordstore.QueryExpression.BBox in project polymap4-core by Polymap4.

the class GeometryValueCoder method searchQuery.

public Query searchQuery(QueryExpression exp) {
    // BBOX
    if (exp instanceof QueryExpression.BBox) {
        // return !(other.minx > maxx ||
        // other.maxx < minx ||
        // other.miny > maxy ||
        // other.maxy < miny);
        // -> !maxx < other.minx && !mixx > other.maxx
        // -> maxx > other.minx && minx < other.maxx
        BBox bbox = (QueryExpression.BBox) exp;
        BooleanQuery result = new BooleanQuery();
        // maxx > bbox.getMinX
        result.add(numeric.searchQuery(new Greater(bbox.key + FIELD_MAXX, bbox.minX)), BooleanClause.Occur.MUST);
        // minx < bbox.getMaxX
        result.add(numeric.searchQuery(new Less(bbox.key + FIELD_MINX, bbox.maxX)), BooleanClause.Occur.MUST);
        // maxy > bbox.getMinY
        result.add(numeric.searchQuery(new Greater(bbox.key + FIELD_MAXY, bbox.minY)), BooleanClause.Occur.MUST);
        // miny < bbox.getMaxY
        result.add(numeric.searchQuery(new Less(bbox.key + FIELD_MINY, bbox.maxY)), BooleanClause.Occur.MUST);
        return result;
    }
    // }
    return null;
}
Also used : BooleanQuery(org.apache.lucene.search.BooleanQuery) BBox(org.polymap.recordstore.QueryExpression.BBox) Greater(org.polymap.recordstore.QueryExpression.Greater) Less(org.polymap.recordstore.QueryExpression.Less)

Aggregations

BooleanQuery (org.apache.lucene.search.BooleanQuery)1 BBox (org.polymap.recordstore.QueryExpression.BBox)1 Greater (org.polymap.recordstore.QueryExpression.Greater)1 Less (org.polymap.recordstore.QueryExpression.Less)1