use of org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree in project lucene-solr by apache.
the class TestRecursivePrefixTreeStrategy method init.
//Tests should call this first.
private void init(int maxLength) {
this.maxLength = maxLength;
this.ctx = SpatialContext.GEO;
GeohashPrefixTree grid = new GeohashPrefixTree(ctx, maxLength);
this.strategy = new RecursivePrefixTreeStrategy(grid, getClass().getSimpleName());
}
use of org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree in project lucene-solr by apache.
the class TestRecursivePrefixTreeStrategy method testOneMeterPrecision.
@Test
public void testOneMeterPrecision() {
init(GeohashPrefixTree.getMaxLevelsPossible());
GeohashPrefixTree grid = (GeohashPrefixTree) ((RecursivePrefixTreeStrategy) strategy).getGrid();
//DWS: I know this to be true. 11 is needed for one meter
double degrees = DistanceUtils.dist2Degrees(0.001, DistanceUtils.EARTH_MEAN_RADIUS_KM);
assertEquals(11, grid.getLevelForDistance(degrees));
}
use of org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree in project lucene-solr by apache.
the class CompositeStrategyTest method setupGeohashGrid.
private void setupGeohashGrid(int maxLevels) {
this.ctx = SpatialContext.GEO;
//A fairly shallow grid
if (maxLevels == -1)
//max 16k cells (32^3)
maxLevels = randomIntBetween(1, 3);
this.grid = new GeohashPrefixTree(ctx, maxLevels);
this.rptStrategy = newRPT();
}
use of org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree in project lucene-solr by apache.
the class SpatialExample method init.
protected void init() {
//Typical geospatial context
// These can also be constructed from SpatialContextFactory
this.ctx = SpatialContext.GEO;
//results in sub-meter precision for geohash
int maxLevels = 11;
//TODO demo lookup by detail distance
// This can also be constructed from SpatialPrefixTreeFactory
SpatialPrefixTree grid = new GeohashPrefixTree(ctx, maxLevels);
this.strategy = new RecursivePrefixTreeStrategy(grid, "myGeoField");
this.directory = new RAMDirectory();
}
use of org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree in project lucene-solr by apache.
the class DistanceStrategyTest 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 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 });
grid = new PackedQuadPrefixTree(ctx, 25);
strategy = new RecursivePrefixTreeStrategy(grid, "recursive_packedquad");
ctorArgs.add(new Object[] { strategy.getFieldName(), strategy });
strategy = PointVectorStrategy.newInstance(ctx, "pointvector");
ctorArgs.add(new Object[] { strategy.getFieldName(), strategy });
// Can't test this without un-inverting since PVS legacy config didn't have docValues.
// However, note that Solr's tests use UninvertingReader and thus test this.
// strategy = PointVectorStrategy.newLegacyInstance(ctx, "pointvector_legacy");
// ctorArgs.add(new Object[]{strategy.getFieldName(), strategy});
strategy = BBoxStrategy.newInstance(ctx, "bbox");
ctorArgs.add(new Object[] { strategy.getFieldName(), strategy });
strategy = new SerializedDVStrategy(ctx, "serialized");
ctorArgs.add(new Object[] { strategy.getFieldName(), strategy });
return ctorArgs;
}
Aggregations