List of usage examples for org.apache.lucene.spatial.query SpatialOperation Contains
SpatialOperation Contains
To view the source code for org.apache.lucene.spatial.query SpatialOperation Contains.
Click Source Link
From source file:com.stratio.cassandra.lucene.search.condition.BitemporalCondition.java
License:Apache License
static SpatialOperation parseSpatialOperation(String operation) { if (operation == null) { throw new IllegalArgumentException("Operation is required"); } else if (operation.equalsIgnoreCase("contains")) { return SpatialOperation.Contains; } else if (operation.equalsIgnoreCase("intersects")) { return SpatialOperation.Intersects; } else if (operation.equalsIgnoreCase("is_within")) { return SpatialOperation.IsWithin; } else {// w w w . j ava 2s. c om throw new IllegalArgumentException("Operation is invalid: " + operation); } }
From source file:com.stratio.cassandra.lucene.search.condition.DateRangeCondition.java
License:Apache License
/** * Returns the {@link SpatialOperation} representing the specified {@code String}. * * @param operation A {@code String} representing a {@link SpatialOperation}. * @return The {@link SpatialOperation} representing the specified {@code String}. *//*from w ww . ja v a 2 s. c o m*/ static SpatialOperation parseSpatialOperation(String operation) { if (operation == null) { throw new IllegalArgumentException("Operation is required"); } else if (operation.equalsIgnoreCase("is_within")) { return SpatialOperation.IsWithin; } else if (operation.equalsIgnoreCase("contains")) { return SpatialOperation.Contains; } else if (operation.equalsIgnoreCase("intersects")) { return SpatialOperation.Intersects; } else { throw new IllegalArgumentException("Operation is invalid: " + operation); } }
From source file:com.stratio.cassandra.lucene.search.condition.DateRangeConditionTest.java
License:Apache License
@Test public void testParseSpatialOperationIContainsLowerCase() { assertEquals(SpatialOperation.Contains, DateRangeCondition.parseSpatialOperation("contains")); }
From source file:com.stratio.cassandra.lucene.search.condition.DateRangeConditionTest.java
License:Apache License
@Test public void testParseSpatialOperationContainsUpperCase() { assertEquals(SpatialOperation.Contains, DateRangeCondition.parseSpatialOperation("CONTAINS")); }
From source file:com.stratio.cassandra.lucene.search.condition.GeoOperationTest.java
License:Apache License
@Test public void testParseContains() { GeoOperation distance = GeoOperation.parse("contains"); check(distance, SpatialOperation.Contains); }
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 w w w . j a v a 2 s . 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;/* www. j a va 2 s . c om*/ _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 ww .java 2s. com // 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 . ja v a 2 s . co 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 o m*/ return null; }