当前位置: 首页>>代码示例>>Java>>正文


Java GeohashPrefixTree类代码示例

本文整理汇总了Java中org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree的典型用法代码示例。如果您正苦于以下问题:Java GeohashPrefixTree类的具体用法?Java GeohashPrefixTree怎么用?Java GeohashPrefixTree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GeohashPrefixTree类属于org.apache.lucene.spatial.prefix.tree包,在下文中一共展示了GeohashPrefixTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRelationSupport

import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree; //导入依赖的package包/类
protected static boolean testRelationSupport(SpatialOperation relation) {
    if (relation == SpatialOperation.IsDisjointTo) {
        // disjoint works in terms of intersection
        relation = SpatialOperation.Intersects;
    }
    try {
        GeohashPrefixTree tree = new GeohashPrefixTree(SpatialContext.GEO, 3);
        RecursivePrefixTreeStrategy strategy = new RecursivePrefixTreeStrategy(tree, "area");
        Shape shape = SpatialContext.GEO.makePoint(0, 0);
        SpatialArgs args = new SpatialArgs(relation, shape);
        strategy.makeQuery(args);
        return true;
    } catch (UnsupportedSpatialOperation e) {
        final SpatialOperation finalRelation = relation;
        ESLoggerFactory
            .getLogger(GeoFilterIT.class.getName())
            .info((Supplier<?>) () -> new ParameterizedMessage("Unsupported spatial operation {}", finalRelation), e);
        return false;
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:GeoFilterIT.java

示例2: testDefaultConfiguration

import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree; //导入依赖的package包/类
public void testDefaultConfiguration() throws IOException {
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
            .startObject("properties").startObject("location")
                .field("type", "geo_shape")
            .endObject().endObject()
            .endObject().endObject().string();

    DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
    FieldMapper fieldMapper = defaultMapper.mappers().getMapper("location");
    assertThat(fieldMapper, instanceOf(GeoShapeFieldMapper.class));

    GeoShapeFieldMapper geoShapeFieldMapper = (GeoShapeFieldMapper) fieldMapper;
    PrefixTreeStrategy strategy = geoShapeFieldMapper.fieldType().defaultStrategy();

    assertThat(strategy.getDistErrPct(), equalTo(0.025d));
    assertThat(strategy.getGrid(), instanceOf(GeohashPrefixTree.class));
    assertThat(strategy.getGrid().getMaxLevels(), equalTo(GeoShapeFieldMapper.Defaults.GEOHASH_LEVELS));
    assertThat(geoShapeFieldMapper.fieldType().orientation(), equalTo(GeoShapeFieldMapper.Defaults.ORIENTATION));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:GeoShapeFieldMapperTests.java

示例3: testGeohashConfiguration

import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree; //导入依赖的package包/类
public void testGeohashConfiguration() throws IOException {
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
            .startObject("properties").startObject("location")
                .field("type", "geo_shape")
                .field("tree", "geohash")
                .field("tree_levels", "4")
                .field("distance_error_pct", "0.1")
            .endObject().endObject()
            .endObject().endObject().string();

    DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
    FieldMapper fieldMapper = defaultMapper.mappers().getMapper("location");
    assertThat(fieldMapper, instanceOf(GeoShapeFieldMapper.class));

    GeoShapeFieldMapper geoShapeFieldMapper = (GeoShapeFieldMapper) fieldMapper;
    PrefixTreeStrategy strategy = geoShapeFieldMapper.fieldType().defaultStrategy();

    assertThat(strategy.getDistErrPct(), equalTo(0.1));
    assertThat(strategy.getGrid(), instanceOf(GeohashPrefixTree.class));
    assertThat(strategy.getGrid().getMaxLevels(), equalTo(4));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:GeoShapeFieldMapperTests.java

示例4: testPointsOnlyOption

import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree; //导入依赖的package包/类
public void testPointsOnlyOption() throws IOException {
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
            .startObject("properties").startObject("location")
            .field("type", "geo_shape")
            .field("tree", "geohash")
            .field("points_only", true)
            .endObject().endObject()
            .endObject().endObject().string();

    DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
    FieldMapper fieldMapper = defaultMapper.mappers().getMapper("location");
    assertThat(fieldMapper, instanceOf(GeoShapeFieldMapper.class));

    GeoShapeFieldMapper geoShapeFieldMapper = (GeoShapeFieldMapper) fieldMapper;
    PrefixTreeStrategy strategy = geoShapeFieldMapper.fieldType().defaultStrategy();

    assertThat(strategy.getGrid(), instanceOf(GeohashPrefixTree.class));
    assertThat(strategy.isPointsOnly(), equalTo(true));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:GeoShapeFieldMapperTests.java

示例5: geoSpeedTest

import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree; //导入依赖的package包/类
@Test
public void geoSpeedTest() throws IOException, ParseException {

  RecursivePrefixTreeStrategy strategy = new RecursivePrefixTreeStrategy(new GeohashPrefixTree(JtsSpatialContext.GEO, 11),
      "location");

  IndexWriterConfig conf = new IndexWriterConfig(new StandardAnalyzer());
  final RAMDirectory directory = new RAMDirectory();
  final IndexWriter writer = new IndexWriter(directory, conf);

  Shape multiPolygon = JtsSpatialContext.GEO
      .getWktShapeParser()
      .parse(
          "MULTIPOLYGON (((15.520376 38.231155, 15.160243 37.444046, 15.309898 37.134219, 15.099988 36.619987, 14.335229 36.996631, 13.826733 37.104531, 12.431004 37.61295, 12.570944 38.126381, 13.741156 38.034966, 14.761249 38.143874, 15.520376 38.231155)), ((9.210012 41.209991, 9.809975 40.500009, 9.669519 39.177376, 9.214818 39.240473, 8.806936 38.906618, 8.428302 39.171847, 8.388253 40.378311, 8.159998 40.950007, 8.709991 40.899984, 9.210012 41.209991)), ((12.376485 46.767559, 13.806475 46.509306, 13.69811 46.016778, 13.93763 45.591016, 13.141606 45.736692, 12.328581 45.381778, 12.383875 44.885374, 12.261453 44.600482, 12.589237 44.091366, 13.526906 43.587727, 14.029821 42.761008, 15.14257 41.95514, 15.926191 41.961315, 16.169897 41.740295, 15.889346 41.541082, 16.785002 41.179606, 17.519169 40.877143, 18.376687 40.355625, 18.480247 40.168866, 18.293385 39.810774, 17.73838 40.277671, 16.869596 40.442235, 16.448743 39.795401, 17.17149 39.4247, 17.052841 38.902871, 16.635088 38.843572, 16.100961 37.985899, 15.684087 37.908849, 15.687963 38.214593, 15.891981 38.750942, 16.109332 38.964547, 15.718814 39.544072, 15.413613 40.048357, 14.998496 40.172949, 14.703268 40.60455, 14.060672 40.786348, 13.627985 41.188287, 12.888082 41.25309, 12.106683 41.704535, 11.191906 42.355425, 10.511948 42.931463, 10.200029 43.920007, 9.702488 44.036279, 8.888946 44.366336, 8.428561 44.231228, 7.850767 43.767148, 7.435185 43.693845, 7.549596 44.127901, 7.007562 44.254767, 6.749955 45.028518, 7.096652 45.333099, 6.802355 45.70858, 6.843593 45.991147, 7.273851 45.776948, 7.755992 45.82449, 8.31663 46.163642, 8.489952 46.005151, 8.966306 46.036932, 9.182882 46.440215, 9.922837 46.314899, 10.363378 46.483571, 10.442701 46.893546, 11.048556 46.751359, 11.164828 46.941579, 12.153088 47.115393, 12.376485 46.767559)))");

  Document doc = new Document();

  for (IndexableField f : strategy.createIndexableFields(multiPolygon)) {
    doc.add(f);
  }

  writer.addDocument(doc);
  writer.commit();

  writer.close();
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:27,代码来源:LuceneGeoTest.java

示例6: testEqualsHashCode

import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree; //导入依赖的package包/类
@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"));
  strategies.add(new BBoxStrategy(ctx, "bbox"));
  strategies.add(new SerializedDVStrategy(ctx, "serialized"));
  for (SpatialStrategy strategy : strategies) {
    testEqualsHashcode(strategy);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:QueryEqualsHashCodeTest.java

示例7: test28

import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree; //导入依赖的package包/类
@Test
public void test28() throws ParseException {
  SpatialContext ctx = SpatialContext.GEO;
  ShapeReadWriter<SpatialContext> shapeReadWriter = new ShapeReadWriter<SpatialContext>(ctx);
  int maxLevels = 11;
  SpatialPrefixTree grid = new GeohashPrefixTree(ctx, maxLevels);
  RecursivePrefixTreeStrategy strategy = new RecursivePrefixTreeStrategy(grid, "a.id_gis", false);
  Circle circle = ctx.makeCircle(-80.0, 33.0, DistanceUtils.dist2Degrees(10, DistanceUtils.EARTH_MEAN_RADIUS_KM));
  SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, circle);

  String writeSpatialArgs = SpatialArgsParser.writeSpatialArgs(args, shapeReadWriter);

  // This has to be done because of rounding.
  SpatialArgs spatialArgs = SpatialArgsParser.parse(writeSpatialArgs, shapeReadWriter);
  Query q1 = sq(strategy.makeQuery(spatialArgs));
  Query q = parseSq("a.id_gis:\"" + writeSpatialArgs + "\"");
  boolean equals = q1.equals(q);
  assertTrue(equals);
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:20,代码来源:SuperParserTest.java

示例8: GeoProperty

import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree; //导入依赖的package包/类
public GeoProperty(Property prop) {
  this.prop = prop;
  this.spatialctx = SpatialContext.GEO;

  int maxlevels = 11; // FIXME: how to compute?
  GeohashPrefixTree grid = new GeohashPrefixTree(spatialctx, maxlevels);
  this.strategy = new RecursivePrefixTreeStrategy(grid, prop.getName());
}
 
开发者ID:enricopal,项目名称:STEM,代码行数:9,代码来源:GeoProperty.java

示例9: setupGeohashGrid

import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree; //导入依赖的package包/类
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());
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:SpatialOpRecursivePrefixTreeTest.java

示例10: testFilterWithVariableScanLevel

import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree; //导入依赖的package包/类
@Test
public void testFilterWithVariableScanLevel() throws IOException {
  init(GeohashPrefixTree.getMaxLevelsPossible());
  getAddAndVerifyIndexedDocuments(DATA_WORLD_CITIES_POINTS);

  //execute queries for each prefix grid scan level
  for(int i = 0; i <= maxLength; i++) {
    ((RecursivePrefixTreeStrategy)strategy).setPrefixGridScanLevel(i);
    executeQueries(SpatialMatchConcern.FILTER, QTEST_Cities_Intersects_BBox);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:12,代码来源:TestRecursivePrefixTreeStrategy.java

示例11: testOneMeterPrecision

import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree; //导入依赖的package包/类
@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));
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:TestRecursivePrefixTreeStrategy.java

示例12: testPrecision

import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree; //导入依赖的package包/类
@Test
public void testPrecision() throws IOException{
  init(GeohashPrefixTree.getMaxLevelsPossible());

  Point iPt = ctx.makePoint(2.8028712999999925, 48.3708044);//lon, lat
  addDocument(newDoc("iPt", iPt));
  commit();

  Point qPt = ctx.makePoint(2.4632387000000335, 48.6003516);

  final double KM2DEG = DistanceUtils.dist2Degrees(1, DistanceUtils.EARTH_MEAN_RADIUS_KM);
  final double DEG2KM = 1 / KM2DEG;

  final double DIST = 35.75;//35.7499...
  assertEquals(DIST, ctx.getDistCalc().distance(iPt, qPt) * DEG2KM, 0.001);

  //distErrPct will affect the query shape precision. The indexed precision
  // was set to nearly zilch via init(GeohashPrefixTree.getMaxLevelsPossible());
  final double distErrPct = 0.025; //the suggested default, by the way
  final double distMult = 1+distErrPct;

  assertTrue(35.74*distMult >= DIST);
  checkHits(q(qPt, 35.74 * KM2DEG, distErrPct), 1, null);

  assertTrue(30*distMult < DIST);
  checkHits(q(qPt, 30 * KM2DEG, distErrPct), 0, null);

  assertTrue(33*distMult < DIST);
  checkHits(q(qPt, 33 * KM2DEG, distErrPct), 0, null);

  assertTrue(34*distMult < DIST);
  checkHits(q(qPt, 34 * KM2DEG, distErrPct), 0, null);
}
 
开发者ID:europeana,项目名称:search,代码行数:34,代码来源:TestRecursivePrefixTreeStrategy.java

示例13: JtsPolygonTest

import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree; //导入依赖的package包/类
public JtsPolygonTest() {
  try {
    HashMap<String, String> args = new HashMap<>();
    args.put("spatialContextFactory",
        "com.spatial4j.core.context.jts.JtsSpatialContextFactory");
    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!)
}
 
开发者ID:europeana,项目名称:search,代码行数:15,代码来源:JtsPolygonTest.java

示例14: init

import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree; //导入依赖的package包/类
protected void init() {
  //Typical geospatial context
  //  These can also be constructed from SpatialContextFactory
  this.ctx = SpatialContext.GEO;

  int maxLevels = 11;//results in sub-meter precision for geohash
  //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();
}
 
开发者ID:europeana,项目名称:search,代码行数:15,代码来源:SpatialExample.java

示例15: GeoShapeMapper

import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree; //导入依赖的package包/类
/**
 * Builds a new {@link GeoShapeMapper}.
 */
@JsonCreator
public GeoShapeMapper(@JsonProperty("max_levels") Integer maxLevels) {
    super(new AbstractType<?>[]{AsciiType.instance, UTF8Type.instance});
    this.maxLevels = maxLevels == null ? DEFAULT_MAX_LEVELS : maxLevels;
    this.grid = new GeohashPrefixTree(spatialContext, this.maxLevels);
}
 
开发者ID:Stratio,项目名称:stratio-cassandra,代码行数:10,代码来源:GeoShapeMapper.java


注:本文中的org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。