• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SpatialContextFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.spatial4j.core.context.SpatialContextFactory的典型用法代码示例。如果您正苦于以下问题:Java SpatialContextFactory类的具体用法?Java SpatialContextFactory怎么用?Java SpatialContextFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SpatialContextFactory类属于com.spatial4j.core.context包,在下文中一共展示了SpatialContextFactory类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: makeSpatialStrategy

import com.spatial4j.core.context.SpatialContextFactory; //导入依赖的package包/类
/**
 * Builds a SpatialStrategy from configuration options.
 */
protected SpatialStrategy makeSpatialStrategy(final Config config) {
  //A Map view of Config that prefixes keys with "spatial."
  Map<String, String> configMap = new AbstractMap<String, String>() {
    @Override
    public Set<Entry<String, String>> entrySet() {
      throw new UnsupportedOperationException();
    }

    @Override
    public String get(Object key) {
      return config.get("spatial." + key, null);
    }
  };

  SpatialContext ctx = SpatialContextFactory.makeSpatialContext(configMap, null);

  //Some day the strategy might be initialized with a factory but such a factory
  // is non-existent.
  return makeSpatialStrategy(config, configMap, ctx);
}
 
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:SpatialDocMaker.java


示例2: init

import com.spatial4j.core.context.SpatialContextFactory; //导入依赖的package包/类
@Override
protected void init(IndexSchema schema, Map<String, String> args) {
  super.init(schema, args);

  String units = args.remove("units");
  if (!"degrees".equals(units))
    throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
        "Must specify units=\"degrees\" on field types with class "+getClass().getSimpleName());

  //Solr expects us to remove the parameters we've used.
  MapListener<String, String> argsWrap = new MapListener<String, String>(args);
  ctx = SpatialContextFactory.makeSpatialContext(argsWrap, schema.getResourceLoader().getClassLoader());
  args.keySet().removeAll(argsWrap.getSeenKeys());

  argsParser = new SpatialArgsParser();//might make pluggable some day?
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:17,代码来源:AbstractSpatialFieldType.java


示例3: init

import com.spatial4j.core.context.SpatialContextFactory; //导入依赖的package包/类
@Override
protected void init(IndexSchema schema, Map<String, String> args) {
  super.init(schema, args);
  //COPIED FROM AbstractSpatialFieldType:
  //Solr expects us to remove the parameters we've used.
  MapListener<String, String> argsWrap = new MapListener<String, String>(args);
  ctx = SpatialContextFactory.makeSpatialContext(argsWrap, schema.getResourceLoader().getClassLoader());
  args.keySet().removeAll(argsWrap.getSeenKeys());
}
 
开发者ID:randomstatistic,项目名称:SOLR-5170,代码行数:10,代码来源:MultiPointDocValuesField.java


示例4: setupCtx2D

import com.spatial4j.core.context.SpatialContextFactory; //导入依赖的package包/类
private void setupCtx2D(SpatialContext ctx) {
  if (!ctx.isGeo())
    ctx2D = ctx;
  //A non-geo version of ctx.
  SpatialContextFactory ctxFactory = new SpatialContextFactory();
  ctxFactory.geo = false;
  ctxFactory.worldBounds = ctx.getWorldBounds();
  ctx2D = ctxFactory.newSpatialContext();
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:SpatialOpRecursivePrefixTreeTest.java


示例5: setupQuadGrid

import com.spatial4j.core.context.SpatialContextFactory; //导入依赖的package包/类
private void setupQuadGrid(int maxLevels) {
  //non-geospatial makes this test a little easier (in gridSnap), and using boundary values 2^X raises
  // the prospect of edge conditions we want to test, plus makes for simpler numbers (no decimals).
  SpatialContextFactory factory = new SpatialContextFactory();
  factory.geo = false;
  factory.worldBounds = new RectangleImpl(0, 256, -128, 128, null);
  this.ctx = factory.newSpatialContext();
  //A fairly shallow grid, and default 2.5% distErrPct
  if (maxLevels == -1)
    maxLevels = randomIntBetween(1, 8);//max 64k cells (4^8), also 256*256
  this.grid = new QuadPrefixTree(ctx, maxLevels);
  this.strategy = new RecursivePrefixTreeStrategy(grid, getClass().getSimpleName());
}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:SpatialOpRecursivePrefixTreeTest.java


示例6: JtsPolygonTest

import com.spatial4j.core.context.SpatialContextFactory; //导入依赖的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


示例7: testOperations

import com.spatial4j.core.context.SpatialContextFactory; //导入依赖的package包/类
@Test
@Repeat(iterations = 20)
public void testOperations() throws IOException {
  //setup
  if (random().nextInt(4) > 0) {//75% of the time choose geo (more interesting to test)
    this.ctx = SpatialContext.GEO;
  } else {
    SpatialContextFactory factory = new SpatialContextFactory();
    factory.geo = false;
    factory.worldBounds = new RectangleImpl(-300, 300, -100, 100, null);
    this.ctx = factory.newSpatialContext();
  }
  this.strategy = new BBoxStrategy(ctx, "bbox");
  //test we can disable docValues for predicate tests
  if (random().nextBoolean()) {
    BBoxStrategy bboxStrategy = (BBoxStrategy) strategy;
    FieldType fieldType = new FieldType(bboxStrategy.getFieldType());
    fieldType.setDocValueType(null);
    bboxStrategy.setFieldType(fieldType);
  }
  for (SpatialOperation operation : SpatialOperation.values()) {
    if (operation == SpatialOperation.Overlaps)
      continue;//unsupported
    testOperationRandomShapes(operation);

    deleteAll();
    commit();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:30,代码来源:TestBBoxStrategy.java


示例8: init

import com.spatial4j.core.context.SpatialContextFactory; //导入依赖的package包/类
@Override
protected void init(IndexSchema schema, Map<String, String> args) {
  super.init(schema, args);

  String units = args.remove("units");
  if (!"degrees".equals(units))
    throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
        "Must specify units=\"degrees\" on field types with class "+getClass().getSimpleName());

  //replace legacy rect format with ENVELOPE
  String wbStr = args.get("worldBounds");
  if (wbStr != null && !wbStr.toUpperCase(Locale.ROOT).startsWith("ENVELOPE")) {
    log.warn("Using old worldBounds format? Should use ENVELOPE(xMin, xMax, yMax, yMin).");
    String[] parts = wbStr.split(" ");//"xMin yMin xMax yMax"
    if (parts.length == 4) {
      args.put("worldBounds",
          "ENVELOPE(" + parts[0] + ", " + parts[2] + ", " + parts[3] + ", " + parts[1] + ")");
    } //else likely eventual exception
  }

  //Solr expects us to remove the parameters we've used.
  MapListener<String, String> argsWrap = new MapListener<>(args);
  ctx = SpatialContextFactory.makeSpatialContext(argsWrap, schema.getResourceLoader().getClassLoader());
  args.keySet().removeAll(argsWrap.getSeenKeys());

  argsParser = newSpatialArgsParser();
}
 
开发者ID:europeana,项目名称:search,代码行数:28,代码来源:AbstractSpatialFieldType.java


示例9: JtsPolygonTest

import com.spatial4j.core.context.SpatialContextFactory; //导入依赖的package包/类
public JtsPolygonTest() {
  try {
    HashMap<String, String> args = new HashMap<String, String>();
    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:pkarmstr,项目名称:NYBC,代码行数:15,代码来源:JtsPolygonTest.java


示例10: init

import com.spatial4j.core.context.SpatialContextFactory; //导入依赖的package包/类
@Override
protected void init(IndexSchema schema, Map<String, String> args) {
  super.init(schema, args);

  String units = args.remove("units");
  if (!"degrees".equals(units))
    throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
        "Must specify units=\"degrees\" on field types with class "+getClass().getSimpleName());

  //replace legacy rect format with ENVELOPE
  String wbStr = args.get("worldBounds");
  if (wbStr != null && !wbStr.toUpperCase(Locale.ROOT).startsWith("ENVELOPE")) {
    log.warn("Using old worldBounds format? Should use ENVELOPE(xMin, xMax, yMax, yMin).");
    String[] parts = wbStr.split(" ");//"xMin yMin xMax yMax"
    if (parts.length == 4) {
      args.put("worldBounds",
          "ENVELOPE(" + parts[0] + ", " + parts[2] + ", " + parts[3] + ", " + parts[1] + ")");
    } //else likely eventual exception
  }

  //Solr expects us to remove the parameters we've used.
  MapListener<String, String> argsWrap = new MapListener<String, String>(args);
  ctx = SpatialContextFactory.makeSpatialContext(argsWrap, schema.getResourceLoader().getClassLoader());
  args.keySet().removeAll(argsWrap.getSeenKeys());

  argsParser = newSpatialArgsParser();
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:28,代码来源:AbstractSpatialFieldType.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SVNLock类代码示例发布时间:2022-05-22
下一篇:
Java ModbusUtil类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap