}
//TODO this is basically old code that hasn't been verified well and should probably be removed
public Query makeQueryDistanceScore(SpatialArgs args) {
// For starters, just limit the bbox
Shape shape = args.getShape();
if (!(shape instanceof Rectangle || shape instanceof Circle)) {
throw new UnsupportedOperationException("Only Rectangles and Circles are currently supported, " +
"found [" + shape.getClass() + "]");//TODO
}
Rectangle bbox = shape.getBoundingBox();
if (bbox.getCrossesDateLine()) {
throw new UnsupportedOperationException( "Crossing dateline not yet supported" );
}
ValueSource valueSource = null;
Query spatial = null;
SpatialOperation op = args.getOperation();
if( SpatialOperation.is( op,
SpatialOperation.BBoxWithin,
SpatialOperation.BBoxIntersects ) ) {
spatial = makeWithin(bbox);
}
else if( SpatialOperation.is( op,
SpatialOperation.Intersects,
SpatialOperation.IsWithin ) ) {
spatial = makeWithin(bbox);
if( args.getShape() instanceof Circle) {
Circle circle = (Circle)args.getShape();
// Make the ValueSource
valueSource = makeDistanceValueSource(shape.getCenter());
ValueSourceFilter vsf = new ValueSourceFilter(
new QueryWrapperFilter( spatial ), valueSource, 0, circle.getRadius() );
spatial = new FilteredQuery( new MatchAllDocsQuery(), vsf );
}
}
else if( op == SpatialOperation.IsDisjointTo ) {
spatial = makeDisjoint(bbox);
}
if( spatial == null ) {
throw new UnsupportedSpatialOperation(args.getOperation());
}
if( valueSource != null ) {
valueSource = new CachingDoubleValueSource(valueSource);
}
else {
valueSource = makeDistanceValueSource(shape.getCenter());
}
Query spatialRankingQuery = new FunctionQuery(valueSource);
BooleanQuery bq = new BooleanQuery();
bq.add(spatial,BooleanClause.Occur.MUST);
bq.add(spatialRankingQuery,BooleanClause.Occur.MUST);