List of usage examples for org.apache.solr.search.function.distance VectorDistanceFunction VectorDistanceFunction
public VectorDistanceFunction(float power, MultiValueSource source1, MultiValueSource source2)
From source file:GeonamesQParserPlugin.java
License:Apache License
private FunctionQuery getFunction(DistType distType, ValueSource ghVS, float power, List<ValueSource> latLon, double currLat, double currLon, double radius) { ValueSource vs = null;/*from www . j ava2 s . co m*/ switch (distType) { case GHHSIN: { String ghStr = GeoHashUtils.encode(currLat, currLon); vs = new GeohashHaversineFunction(new LiteralValueSource(ghStr), ghVS, radius); break; } case HSIN: { vs = new HaversineFunction(new ConstValueSource((float) currLat), new ConstValueSource((float) currLon), latLon.get(0), latLon.get(1), radius); break; } case NORM: { List<ValueSource> current = new ArrayList<ValueSource>(2); current.add(new ConstValueSource((float) currLat)); current.add(new ConstValueSource((float) currLon)); vs = new VectorDistanceFunction(power, latLon, current); break; } default: {//assume 2-norm List<ValueSource> current = new ArrayList<ValueSource>(2); current.add(new ConstValueSource((float) currLat)); current.add(new ConstValueSource((float) currLon)); vs = new VectorDistanceFunction(2, latLon, current); break; } } return new FunctionQuery(new ReciprocalFloatFunction(vs, 1, 1, 0)); // 1/distance }