Example usage for org.apache.lucene.spatial.vector PointVectorStrategy newInstance

List of usage examples for org.apache.lucene.spatial.vector PointVectorStrategy newInstance

Introduction

In this page you can find the example usage for org.apache.lucene.spatial.vector PointVectorStrategy newInstance.

Prototype

public static PointVectorStrategy newInstance(SpatialContext ctx, String fieldNamePrefix) 

Source Link

Document

Create a new PointVectorStrategy instance that uses DoublePoint and DoublePoint#newRangeQuery

Usage

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

License:Apache License

private SpatialStrategy getSpatialStrategy(String key, KeyInformation ki) {
    SpatialStrategy strategy = spatial.get(key);
    final Mapping mapping = Mapping.getMapping(ki);
    final int maxLevels = ParameterType.INDEX_GEO_MAX_LEVELS.findParameter(ki.getParameters(),
            DEFAULT_GEO_MAX_LEVELS);//  ww  w  .  j  a v a  2s  .c  om
    final double distErrorPct = ParameterType.INDEX_GEO_DIST_ERROR_PCT.findParameter(ki.getParameters(),
            DEFAULT_GEO_DIST_ERROR_PCT);
    if (strategy == null) {
        synchronized (spatial) {
            if (!spatial.containsKey(key)) {
                //                    SpatialPrefixTree grid = new GeohashPrefixTree(ctx, GEO_MAX_LEVELS);
                //                    strategy = new RecursivePrefixTreeStrategy(grid, key);
                if (mapping == Mapping.DEFAULT) {
                    strategy = PointVectorStrategy.newInstance(ctx, key);
                } else {
                    final SpatialPrefixTree grid = new QuadPrefixTree(ctx, maxLevels);
                    strategy = new RecursivePrefixTreeStrategy(grid, key);
                    ((PrefixTreeStrategy) strategy).setDistErrPct(distErrorPct);
                }
                spatial.put(key, strategy);
            } else
                return spatial.get(key);
        }
    }
    return strategy;
}