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


Java SpatialStrategy类代码示例

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


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

示例1: build

import org.apache.lucene.spatial.SpatialStrategy; //导入依赖的package包/类
@Override
  public SpatialQueryContext build(Map<String, Object> query) throws Exception {
    Shape shape = parseShape(query);

    System.out.println("qui:: " + shape);
    SpatialStrategy strategy = manager.strategy();
    if (isOnlyBB(strategy)) {
      shape = shape.getBoundingBox();
    }
    SpatialArgs args1 = new SpatialArgs(SpatialOperation.IsWithin, shape);

//    SpatialArgs args2 = new SpatialArgs(SpatialOperation., shape);



    Geometry geo = OShapeFactory.INSTANCE.toGeometry(shape);

    Filter filter = strategy.makeFilter(args1);
    return new SpatialQueryContext(null, manager.searcher(), new MatchAllDocsQuery(), filter);
  }
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:21,代码来源:SpatialQueryBuilderDWithin.java

示例2: makeSpatialStrategy

import org.apache.lucene.spatial.SpatialStrategy; //导入依赖的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

示例3: build

import org.apache.lucene.spatial.SpatialStrategy; //导入依赖的package包/类
@Override
public SpatialQueryContext build(Map<String, Object> query) throws Exception {
  Shape shape = parseShape(query);
  SpatialStrategy strategy = manager.strategy();

  if (isOnlyBB(strategy)) {
    shape = shape.getBoundingBox();
  }
  SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, shape);
  Filter filter = strategy.makeFilter(args);
  return new SpatialQueryContext(null, manager.searcher(), new MatchAllDocsQuery(), filter);
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:13,代码来源:SpatialQueryBuilderContains.java

示例4: build

import org.apache.lucene.spatial.SpatialStrategy; //导入依赖的package包/类
@Override
public SpatialQueryContext build(Map<String, Object> query) throws Exception {
  Shape shape = parseShape(query);

  SpatialStrategy strategy = manager.strategy();
  if (isOnlyBB(strategy)) {
    shape = shape.getBoundingBox();
  }
  SpatialArgs args = new SpatialArgs(SpatialOperation.IsWithin, shape);
  Filter filter = strategy.makeFilter(args);
  return new SpatialQueryContext(null, manager.searcher(), new MatchAllDocsQuery(), filter);
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:13,代码来源:SpatialQueryBuilderWithin.java

示例5: build

import org.apache.lucene.spatial.SpatialStrategy; //导入依赖的package包/类
@Override
public SpatialQueryContext build(Map<String, Object> query) throws Exception {
  Shape shape = parseShape(query);
  SpatialStrategy strategy = manager.strategy();
  SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, shape.getBoundingBox());
  Filter filter = strategy.makeFilter(args);
  return new SpatialQueryContext(null, manager.searcher(), new MatchAllDocsQuery(), filter);
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:9,代码来源:SpatialQueryBuilderOverlap.java

示例6: getSpatialStrategy

import org.apache.lucene.spatial.SpatialStrategy; //导入依赖的package包/类
/**
 * Looks up the SpatialStrategy from the given round --
 * {@link org.apache.lucene.benchmark.byTask.utils.Config#getRoundNumber()}. It's an error
 * if it wasn't created already for this round -- when SpatialDocMaker is initialized.
 */
public static SpatialStrategy getSpatialStrategy(int roundNumber) {
  SpatialStrategy result = spatialStrategyCache.get(roundNumber);
  if (result == null) {
    throw new IllegalStateException("Strategy should have been init'ed by SpatialDocMaker by now");
  }
  return result;
}
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:SpatialDocMaker.java

示例7: setConfig

import org.apache.lucene.spatial.SpatialStrategy; //导入依赖的package包/类
@Override
public void setConfig(Config config, ContentSource source) {
  super.setConfig(config, source);
  SpatialStrategy existing = spatialStrategyCache.get(config.getRoundNumber());
  if (existing == null) {
    //new round; we need to re-initialize
    strategy = makeSpatialStrategy(config);
    spatialStrategyCache.put(config.getRoundNumber(), strategy);
    //TODO remove previous round config?
    shapeConverter = makeShapeConverter(strategy, config, "doc.spatial.");
    System.out.println("Spatial Strategy: " + strategy);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:SpatialDocMaker.java

示例8: makeShapeConverter

import org.apache.lucene.spatial.SpatialStrategy; //导入依赖的package包/类
/**
 * Optionally converts points to circles, and optionally bbox'es result.
 */
public static ShapeConverter makeShapeConverter(final SpatialStrategy spatialStrategy,
                                                Config config, String configKeyPrefix) {
  //by default does no conversion
  final double radiusDegrees = config.get(configKeyPrefix+"radiusDegrees", 0.0);
  final double plusMinus = config.get(configKeyPrefix+"radiusDegreesRandPlusMinus", 0.0);
  final boolean bbox = config.get(configKeyPrefix + "bbox", false);

  return new ShapeConverter() {
    @Override
    public Shape convert(Shape shape) {
      if (shape instanceof Point && (radiusDegrees != 0.0 || plusMinus != 0.0)) {
        Point point = (Point)shape;
        double radius = radiusDegrees;
        if (plusMinus > 0.0) {
          Random random = new Random(point.hashCode());//use hashCode so it's reproducibly random
          radius += random.nextDouble() * 2 * plusMinus - plusMinus;
          radius = Math.abs(radius);//can happen if configured plusMinus > radiusDegrees
        }
        shape = spatialStrategy.getSpatialContext().makeCircle(point, radius);
      }
      if (bbox)
        shape = shape.getBoundingBox();
      return shape;
    }
  };
}
 
开发者ID:europeana,项目名称:search,代码行数:30,代码来源:SpatialDocMaker.java

示例9: makeShapeFromString

import org.apache.lucene.spatial.SpatialStrategy; //导入依赖的package包/类
public static Shape makeShapeFromString(SpatialStrategy strategy, String name, String shapeStr) {
  if (shapeStr != null && shapeStr.length() > 0) {
    try {
      return strategy.getSpatialContext().readShapeFromWkt(shapeStr);
    } catch (Exception e) {//InvalidShapeException TODO
      System.err.println("Shape "+name+" wasn't parseable: "+e+"  (skipping it)");
      return null;
    }
  }
  return null;
}
 
开发者ID:europeana,项目名称:search,代码行数:12,代码来源:SpatialDocMaker.java

示例10: makeShapeFromString

import org.apache.lucene.spatial.SpatialStrategy; //导入依赖的package包/类
public static Shape makeShapeFromString(SpatialStrategy strategy, String name, String shapeStr) {
  if (shapeStr != null && shapeStr.length() > 0) {
    try {
      return strategy.getSpatialContext().readShape(shapeStr);
    } catch (Exception e) {//InvalidShapeException TODO
      System.err.println("Shape "+name+" wasn't parseable: "+e+"  (skipping it)");
      return null;
    }
  }
  return null;
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:12,代码来源:SpatialDocMaker.java

示例11: strategy

import org.apache.lucene.spatial.SpatialStrategy; //导入依赖的package包/类
@Override
public SpatialStrategy strategy() {
  return strategy;
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:5,代码来源:OLuceneSpatialIndexEngineAbstract.java

示例12: createSpatialStrategy

import org.apache.lucene.spatial.SpatialStrategy; //导入依赖的package包/类
@Override
protected SpatialStrategy createSpatialStrategy(OIndexDefinition indexDefinition, ODocument metadata) {
  return new RecursivePrefixTreeStrategy(new GeohashPrefixTree(ctx, 11), "location");
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:5,代码来源:OLuceneLegacySpatialIndexEngine.java

示例13: isOnlyBB

import org.apache.lucene.spatial.SpatialStrategy; //导入依赖的package包/类
protected boolean isOnlyBB(SpatialStrategy spatialStrategy) {
  return spatialStrategy instanceof BBoxStrategy;
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:4,代码来源:SpatialQueryBuilderAbstract.java

示例14: SpatialStrategyMultiValueSource

import org.apache.lucene.spatial.SpatialStrategy; //导入依赖的package包/类
public SpatialStrategyMultiValueSource(SpatialStrategy strategy) {
  super(Collections.EMPTY_LIST);
  this.strategy = strategy;
}
 
开发者ID:europeana,项目名称:search,代码行数:5,代码来源:GeoDistValueSourceParser.java

示例15: SpatialStrategyMultiValueSource

import org.apache.lucene.spatial.SpatialStrategy; //导入依赖的package包/类
public SpatialStrategyMultiValueSource(SpatialStrategy strategy) {
    super(Collections.EMPTY_LIST);
    this.strategy = strategy;
}
 
开发者ID:gogobot,项目名称:solr-distance-cluster,代码行数:5,代码来源:DistanceParser.java


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