Java Code Examples for org.apache.lucene.spatial.query.SpatialOperation#IsDisjointTo
The following examples show how to use
org.apache.lucene.spatial.query.SpatialOperation#IsDisjointTo .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LuceneIndex.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
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; } return null; }
Example 2
Source File: BBoxStrategy.java From lucene-solr with Apache License 2.0 | 6 votes |
@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; // 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); }
Example 3
Source File: CompositeStrategyTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testOperations() throws IOException { //setup if (randomBoolean()) { setupQuadGrid(-1); } else { setupGeohashGrid(-1); } SerializedDVStrategy serializedDVStrategy = new SerializedDVStrategy(ctx, getClass().getSimpleName() + "_sdv"); this.strategy = new CompositeSpatialStrategy("composite_" + getClass().getSimpleName(), rptStrategy, serializedDVStrategy); //Do it! for (SpatialOperation pred : SpatialOperation.values()) { if (pred == SpatialOperation.BBoxIntersects || pred == SpatialOperation.BBoxWithin) { continue; } if (pred == SpatialOperation.IsDisjointTo) {//TODO continue; } testOperationRandomShapes(pred); deleteAll(); commit(); } }
Example 4
Source File: BBoxStrategy.java From lucene-solr with Apache License 2.0 | 6 votes |
@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; // 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); }
Example 5
Source File: LuceneQueryBuilder.java From Elasticsearch with Apache License 2.0 | 5 votes |
private SpatialArgs getArgs(Shape shape, ShapeRelation relation) { switch (relation) { case INTERSECTS: return new SpatialArgs(SpatialOperation.Intersects, shape); case DISJOINT: return new SpatialArgs(SpatialOperation.IsDisjointTo, shape); case WITHIN: return new SpatialArgs(SpatialOperation.IsWithin, shape); } throw invalidMatchType(relation.getRelationName()); }
Example 6
Source File: GeoShapeQueryParser.java From Elasticsearch with Apache License 2.0 | 5 votes |
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: return new SpatialArgs(SpatialOperation.IsWithin, shape.build()); case CONTAINS: return new SpatialArgs(SpatialOperation.Contains, shape.build()); default: throw new IllegalArgumentException(""); } }
Example 7
Source File: RecursivePrefixTreeStrategy.java From incubator-retired-blur with Apache License 2.0 | 5 votes |
@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); } 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); }
Example 8
Source File: ToMatchQuery.java From crate with Apache License 2.0 | 5 votes |
private SpatialArgs getArgs(Shape shape, ShapeRelation relation) { switch (relation) { case INTERSECTS: return new SpatialArgs(SpatialOperation.Intersects, shape); case DISJOINT: return new SpatialArgs(SpatialOperation.IsDisjointTo, shape); case WITHIN: return new SpatialArgs(SpatialOperation.IsWithin, shape); default: throw invalidMatchType(relation.getRelationName()); } }