Exemplo n.º 1
0
            //public override Explanation CustomExplain(int doc, Explanation subQueryExpl, Explanation valSrcExpl)
            //{
            //    float valSrcScore = valSrcExpl == null ? 0 : valSrcExpl.Value;
            //    var exp = new Explanation(valSrcScore + subQueryExpl.Value, "custom score: sum of:");
            //    exp.AddDetail(subQueryExpl);
            //    if (valSrcExpl != null)
            //    {
            //        exp.AddDetail(valSrcExpl);
            //    }
            //    return exp;
            //}

            //public override Explanation CustomExplain(int doc, Explanation subQueryExpl, Explanation[] valSrcExpls)
            //{

            //    return base.CustomExplain(doc, subQueryExpl, valSrcExpls);
            //}

            private float CalculateDistance(int doc)
            {
                var x = _currentReaderValuesX[doc];
                var y = _currentReaderValuesY[doc];

                var context = _strategy.GetSpatialContext();

                var pt = context.MakePoint(x, y);

                return((float)context.GetDistCalc().Distance(pt, _originPt));
            }
Exemplo n.º 2
0
        public static TopDocs DistanceQueryAndSort_PointVectorStrategy(Searcher searcher, PointVectorStrategy strategy, Point myLocation)
        {
            var ctx = strategy.GetSpatialContext();

            var q = strategy.MakeQuery(new SpatialArgs(
                                           SpatialOperation.IsWithin,
                                           ctx.MakeCircle(myLocation, DistanceUtils.Dist2Degrees(20000, DistanceUtils.EARTH_MEAN_RADIUS_KM))));

            TopDocs hits = searcher.Search(q, null, 100, new Sort(new SortField("pointvector", new PointVectorDistanceFieldComparatorSource(myLocation, strategy))));

            return(hits);
        }
Exemplo n.º 3
0
        public static TopDocs DistanceFilter_PointVectorStrategy(Searcher searcher, PointVectorStrategy strategy, Point myLocation)
        {
            var ctx = strategy.GetSpatialContext();

            var q      = new MatchAllDocsQuery();
            var filter = strategy.MakeFilter(new SpatialArgs(SpatialOperation.IsWithin,
                                                             ctx.MakeCircle(myLocation,
                                                                            DistanceUtils.Dist2Degrees(2000,
                                                                                                       DistanceUtils
                                                                                                       .EARTH_MEAN_RADIUS_KM))));
            TopDocs hits = searcher.Search(q, filter, 100);

            return(hits);
        }