本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}
};
}
示例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;
}
示例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;
}
示例11: strategy
import org.apache.lucene.spatial.SpatialStrategy; //导入依赖的package包/类
@Override
public SpatialStrategy strategy() {
return strategy;
}
示例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");
}
示例13: isOnlyBB
import org.apache.lucene.spatial.SpatialStrategy; //导入依赖的package包/类
protected boolean isOnlyBB(SpatialStrategy spatialStrategy) {
return spatialStrategy instanceof BBoxStrategy;
}
示例14: SpatialStrategyMultiValueSource
import org.apache.lucene.spatial.SpatialStrategy; //导入依赖的package包/类
public SpatialStrategyMultiValueSource(SpatialStrategy strategy) {
super(Collections.EMPTY_LIST);
this.strategy = strategy;
}
示例15: SpatialStrategyMultiValueSource
import org.apache.lucene.spatial.SpatialStrategy; //导入依赖的package包/类
public SpatialStrategyMultiValueSource(SpatialStrategy strategy) {
super(Collections.EMPTY_LIST);
this.strategy = strategy;
}