Package org.apache.lucene.spatial.prefix.tree

Examples of org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree


  //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());
  }
View Full Code Here


  }

  @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));
  }
View Full Code Here

  public void setupGeohashGrid(int maxLevels) {
    this.ctx = SpatialContext.GEO;
    //A fairly shallow grid, and default 2.5% distErrPct
    if (maxLevels == -1)
      maxLevels = randomIntBetween(1, 3);//max 16k cells (32^3)
    this.grid = new GeohashPrefixTree(ctx, maxLevels);
    this.strategy = new RecursivePrefixTreeStrategy(grid, getClass().getSimpleName());
  }
View Full Code Here

  @Test
  public void testEqualsHashCode() {

    final SpatialPrefixTree gridQuad = new QuadPrefixTree(ctx,10);
    final SpatialPrefixTree gridGeohash = new GeohashPrefixTree(ctx,10);

    Collection<SpatialStrategy> strategies = new ArrayList<>();
    strategies.add(new RecursivePrefixTreeStrategy(gridGeohash, "recursive_geohash"));
    strategies.add(new TermQueryPrefixTreeStrategy(gridQuad, "termquery_quad"));
    strategies.add(new PointVectorStrategy(ctx, "pointvector"));
View Full Code Here

      ctx = SpatialContextFactory.makeSpatialContext(args, getClass().getClassLoader());
    } catch (NoClassDefFoundError e) {
      assumeTrue("This test requires JTS jar: "+e, false);
    }

    GeohashPrefixTree grid = new GeohashPrefixTree(ctx, 11);//< 1 meter == 11 maxLevels
    this.strategy = new RecursivePrefixTreeStrategy(grid, getClass().getSimpleName());
    ((RecursivePrefixTreeStrategy)this.strategy).setDistErrPct(LUCENE_4464_distErrPct);//1% radius (small!)
  }
View Full Code Here

    this.directory = directory;
    this.docDef = def;

    int maxLevels = 11;// results in sub-meter precision for geohash
    // This can also be constructed from SpatialPrefixTreeFactory
    SpatialPrefixTree grid = new GeohashPrefixTree(SpatialQuery.ctx, maxLevels);

    this.strategy = new RecursivePrefixTreeStrategy(grid, def.getGeoField());

    //this.strategy = new PointVectorStrategy(ctx, def.getGeoField());
   
View Full Code Here

    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;
    }
View Full Code Here

        @Override
        public GeoShapeFieldMapper build(BuilderContext context) {

            final FieldMapper.Names names = buildNames(context);
            if (Names.TREE_GEOHASH.equals(tree)) {
                prefixTree = new GeohashPrefixTree(ShapeBuilder.SPATIAL_CONTEXT, getLevels(treeLevels, precisionInMeters, Defaults.GEOHASH_LEVELS, true));
            } else if (Names.TREE_QUADTREE.equals(tree)) {
                prefixTree = new QuadPrefixTree(ShapeBuilder.SPATIAL_CONTEXT, getLevels(treeLevels, precisionInMeters, Defaults.QUADTREE_LEVELS, false));
            } else {
                throw new ElasticsearchIllegalArgumentException("Unknown prefix tree type [" + tree + "]");
            }
View Full Code Here

TOP

Related Classes of org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.