Search in sources :

Example 11 with GeohashPrefixTree

use of org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree in project titan by thinkaurelius.

the class LuceneExample method getSpatialStrategy.

private SpatialStrategy getSpatialStrategy(String key) {
    SpatialStrategy strategy = spatial.get(key);
    if (strategy == null) {
        final int maxLevels = 11;
        SpatialPrefixTree grid = new GeohashPrefixTree(ctx, maxLevels);
        strategy = new RecursivePrefixTreeStrategy(grid, key);
        spatial.put(key, strategy);
    }
    return strategy;
}
Also used : RecursivePrefixTreeStrategy(org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy) SpatialPrefixTree(org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree) SpatialStrategy(org.apache.lucene.spatial.SpatialStrategy) GeohashPrefixTree(org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree)

Example 12 with GeohashPrefixTree

use of org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree in project lucene-solr by apache.

the class PortedSolr3Test method parameters.

@ParametersFactory(argumentFormatting = "strategy=%s")
public static Iterable<Object[]> parameters() {
    List<Object[]> ctorArgs = new ArrayList<>();
    SpatialContext ctx = SpatialContext.GEO;
    SpatialPrefixTree grid;
    SpatialStrategy strategy;
    grid = new GeohashPrefixTree(ctx, 12);
    strategy = new RecursivePrefixTreeStrategy(grid, "recursive_geohash");
    ctorArgs.add(new Object[] { strategy.getFieldName(), strategy });
    grid = new QuadPrefixTree(ctx, 25);
    strategy = new RecursivePrefixTreeStrategy(grid, "recursive_quad");
    ctorArgs.add(new Object[] { strategy.getFieldName(), strategy });
    grid = new GeohashPrefixTree(ctx, 12);
    strategy = new TermQueryPrefixTreeStrategy(grid, "termquery_geohash");
    ctorArgs.add(new Object[] { strategy.getFieldName(), strategy });
    strategy = PointVectorStrategy.newInstance(ctx, "pointvector");
    ctorArgs.add(new Object[] { strategy.getFieldName(), strategy });
    strategy = PointVectorStrategy.newInstance(ctx, "pointvector_legacy");
    ctorArgs.add(new Object[] { strategy.getFieldName(), strategy });
    return ctorArgs;
}
Also used : SpatialContext(org.locationtech.spatial4j.context.SpatialContext) QuadPrefixTree(org.apache.lucene.spatial.prefix.tree.QuadPrefixTree) ArrayList(java.util.ArrayList) RecursivePrefixTreeStrategy(org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy) SpatialPrefixTree(org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree) TermQueryPrefixTreeStrategy(org.apache.lucene.spatial.prefix.TermQueryPrefixTreeStrategy) GeohashPrefixTree(org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree) ParametersFactory(com.carrotsearch.randomizedtesting.annotations.ParametersFactory)

Example 13 with GeohashPrefixTree

use of org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree in project lucene-solr by apache.

the class QueryEqualsHashCodeTest method testEqualsHashCode.

@Test
public void testEqualsHashCode() {
    switch(//0-3
    random().nextInt(4)) {
        case 0:
            predicate = SpatialOperation.Contains;
            break;
        case 1:
            predicate = SpatialOperation.IsWithin;
            break;
        default:
            predicate = SpatialOperation.Intersects;
            break;
    }
    final SpatialPrefixTree gridQuad = new QuadPrefixTree(ctx, 10);
    final SpatialPrefixTree gridGeohash = new GeohashPrefixTree(ctx, 10);
    Collection<SpatialStrategy> strategies = new ArrayList<>();
    RecursivePrefixTreeStrategy recursive_geohash = new RecursivePrefixTreeStrategy(gridGeohash, "recursive_geohash");
    strategies.add(recursive_geohash);
    strategies.add(new TermQueryPrefixTreeStrategy(gridQuad, "termquery_quad"));
    strategies.add(PointVectorStrategy.newInstance(ctx, "pointvector"));
    strategies.add(BBoxStrategy.newInstance(ctx, "bbox"));
    final SerializedDVStrategy serialized = new SerializedDVStrategy(ctx, "serialized");
    strategies.add(serialized);
    strategies.add(new CompositeSpatialStrategy("composite", recursive_geohash, serialized));
    for (SpatialStrategy strategy : strategies) {
        testEqualsHashcode(strategy);
    }
}
Also used : CompositeSpatialStrategy(org.apache.lucene.spatial.composite.CompositeSpatialStrategy) QuadPrefixTree(org.apache.lucene.spatial.prefix.tree.QuadPrefixTree) ArrayList(java.util.ArrayList) RecursivePrefixTreeStrategy(org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy) SpatialPrefixTree(org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree) CompositeSpatialStrategy(org.apache.lucene.spatial.composite.CompositeSpatialStrategy) TermQueryPrefixTreeStrategy(org.apache.lucene.spatial.prefix.TermQueryPrefixTreeStrategy) SerializedDVStrategy(org.apache.lucene.spatial.serialized.SerializedDVStrategy) GeohashPrefixTree(org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree) Test(org.junit.Test)

Example 14 with GeohashPrefixTree

use of org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree in project lucene-solr by apache.

the class Geo3dRptTest method setupGeohashGrid.

private void setupGeohashGrid() {
    //A fairly shallow grid
    this.grid = new GeohashPrefixTree(ctx, 2);
    this.rptStrategy = newRPT();
}
Also used : GeohashPrefixTree(org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree)

Example 15 with GeohashPrefixTree

use of org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree in project lucene-solr by apache.

the class RandomSpatialOpFuzzyPrefixTreeTest method setupGeohashGrid.

public void setupGeohashGrid(int maxLevels) {
    this.ctx = SpatialContext.GEO;
    //A fairly shallow grid, and default 2.5% distErrPct
    if (maxLevels == -1)
        //max 16k cells (32^3)
        maxLevels = randomIntBetween(1, 3);
    this.grid = new GeohashPrefixTree(ctx, maxLevels);
    this.strategy = newRPT();
}
Also used : GeohashPrefixTree(org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree)

Aggregations

GeohashPrefixTree (org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree)17 RecursivePrefixTreeStrategy (org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy)11 SpatialPrefixTree (org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree)10 SpatialStrategy (org.apache.lucene.spatial.SpatialStrategy)5 QuadPrefixTree (org.apache.lucene.spatial.prefix.tree.QuadPrefixTree)4 ArrayList (java.util.ArrayList)3 TermQueryPrefixTreeStrategy (org.apache.lucene.spatial.prefix.TermQueryPrefixTreeStrategy)3 SpatialContext (org.locationtech.spatial4j.context.SpatialContext)3 ParametersFactory (com.carrotsearch.randomizedtesting.annotations.ParametersFactory)2 SpatialArgs (org.apache.lucene.spatial.query.SpatialArgs)2 SerializedDVStrategy (org.apache.lucene.spatial.serialized.SerializedDVStrategy)2 GeoEntry (org.codice.ddf.spatial.geocoding.GeoEntry)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 ParameterizedMessage (org.apache.logging.log4j.message.ParameterizedMessage)1 Supplier (org.apache.logging.log4j.util.Supplier)1 IndexWriter (org.apache.lucene.index.IndexWriter)1 CompositeSpatialStrategy (org.apache.lucene.spatial.composite.CompositeSpatialStrategy)1 Cell (org.apache.lucene.spatial.prefix.tree.Cell)1 PackedQuadPrefixTree (org.apache.lucene.spatial.prefix.tree.PackedQuadPrefixTree)1