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

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

Introduction

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

Prototype

SpatialOperation IsDisjointTo

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

Click Source Link

Document

Meets the "Disjoint" OGC definition.

Usage

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  ww w. j a  v  a2s .  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.SpatialRecursivePrefixTreeStrategyFieldTypeDefinition.java

License:Apache License

@Override
public void configure(String fieldNameForThisInstance, Map<String, String> properties,
        Configuration configuration) {
    _ctx = SpatialContext.GEO;//  w w  w  .j  a  v  a  2s. c  o m
    _grid = getSpatialPrefixTree(fieldNameForThisInstance, properties);
    boolean docValue = false;
    if (properties.get(DOC_VALUE) != null) {
        docValue = true;
    }
    _strategy = new RecursivePrefixTreeStrategy(_grid, fieldNameForThisInstance, docValue);
    _shapeReadWriter = new ShapeReadWriter<SpatialContext>(_ctx);
    addSupportedIndexedShapes(Shape.class);
    addSupportedOperations(SpatialOperation.IsDisjointTo);
    addSupportedOperations(SpatialOperation.Intersects);
    addSupportedOperations(SpatialOperation.IsWithin);
    addSupportedOperations(SpatialOperation.Contains);
}

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;/* 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.codelibs.elasticsearch.index.query.GeoShapeQueryBuilder.java

License:Apache License

public static SpatialArgs getArgs(ShapeBuilder shape, ShapeRelation relation) {
    switch (relation) {
    case DISJOINT:
        return new SpatialArgs(SpatialOperation.IsDisjointTo, shape.build());
    case INTERSECTS:
        return new SpatialArgs(SpatialOperation.Intersects, shape.build());
    case WITHIN:/*from   w w  w.  j a  va 2  s.  c o m*/
        return new SpatialArgs(SpatialOperation.IsWithin, shape.build());
    case CONTAINS:
        return new SpatialArgs(SpatialOperation.Contains, shape.build());
    default:
        throw new IllegalArgumentException("invalid relation [" + relation + "]");
    }
}

From source file:org.eclipse.rdf4j.sail.lucene.LuceneIndex.java

License:Open Source License

private SpatialOperation toSpatialOp(String relation) {
    if (GEOF.SF_INTERSECTS.stringValue().equals(relation)) {
        return SpatialOperation.Intersects;
    } else if (GEOF.SF_DISJOINT.stringValue().equals(relation)) {
        return SpatialOperation.IsDisjointTo;
    } else if (GEOF.SF_EQUALS.stringValue().equals(relation)) {
        return SpatialOperation.IsEqualTo;
    } else if (GEOF.SF_OVERLAPS.stringValue().equals(relation)) {
        return SpatialOperation.Overlaps;
    } else if (GEOF.EH_COVERED_BY.stringValue().equals(relation)) {
        return SpatialOperation.IsWithin;
    } else if (GEOF.EH_COVERS.stringValue().equals(relation)) {
        return SpatialOperation.Contains;
    }/* w  w  w .j  a va  2s. c  om*/
    return null;
}

From source file:org.elasticsearch.index.query.GeoShapeQueryParser.java

License:Apache License

public static SpatialArgs getArgs(ShapeBuilder shape, ShapeRelation relation) {
    switch (relation) {
    case DISJOINT:
        return new SpatialArgs(SpatialOperation.IsDisjointTo, shape.build());
    case INTERSECTS:
        return new SpatialArgs(SpatialOperation.Intersects, shape.build());
    case WITHIN:/*w ww  .  j  a v a 2 s  . c  o  m*/
        return new SpatialArgs(SpatialOperation.IsWithin, shape.build());
    default:
        throw new ElasticsearchIllegalArgumentException("");

    }
}

From source file:org.elasticsearch.search.geo.GeoFilterIT.java

License:Apache License

@BeforeClass
public static void createNodes() throws Exception {
    intersectSupport = testRelationSupport(SpatialOperation.Intersects);
    disjointSupport = testRelationSupport(SpatialOperation.IsDisjointTo);
    withinSupport = testRelationSupport(SpatialOperation.IsWithin);
}

From source file:org.elasticsearch.search.geo.GeoFilterIT.java

License:Apache License

protected static boolean testRelationSupport(SpatialOperation relation) {
    if (relation == SpatialOperation.IsDisjointTo) {
        // disjoint works in terms of intersection
        relation = SpatialOperation.Intersects;
    }/*from   w w w  . j  a v a 2s .c om*/
    try {
        GeohashPrefixTree tree = new GeohashPrefixTree(SpatialContext.GEO, 3);
        RecursivePrefixTreeStrategy strategy = new RecursivePrefixTreeStrategy(tree, "area");
        Shape shape = SpatialContext.GEO.makePoint(0, 0);
        SpatialArgs args = new SpatialArgs(relation, shape);
        strategy.makeQuery(args);
        return true;
    } catch (UnsupportedSpatialOperation e) {
        e.printStackTrace();
        return false;
    }
}

From source file:org.elasticsearch.test.integration.search.geo.GeoFilterTests.java

License:Apache License

@BeforeClass
public void createNodes() throws Exception {
    startNode("server1");
    startNode("server2");

    intersectSupport = testRelationSupport(SpatialOperation.Intersects);
    disjointSupport = testRelationSupport(SpatialOperation.IsDisjointTo);
    withinSupport = testRelationSupport(SpatialOperation.IsWithin);

    client = getClient();// w w  w . j a  v  a 2  s .  c om
}

From source file:org.janusgraph.diskstorage.lucene.LuceneIndex.java

License:Apache License

private static Map<Geo, SpatialOperation> spatialPredicates() {
    return Collections.unmodifiableMap(Stream
            .of(new SimpleEntry<>(Geo.WITHIN, SpatialOperation.IsWithin),
                    new SimpleEntry<>(Geo.CONTAINS, SpatialOperation.Contains),
                    new SimpleEntry<>(Geo.INTERSECT, SpatialOperation.Intersects),
                    new SimpleEntry<>(Geo.DISJOINT, SpatialOperation.IsDisjointTo))
            .collect(Collectors.toMap(SimpleEntry::getKey, SimpleEntry::getValue)));
}