コード例 #1
0
        ///<inheritdoc/>
        public (IEnumerable <IndexEntry <T> > Entries, string Geohash) Query(string geohash, int minimumHits = 1, bool lockPrecision = false, T exclude = default)
        {
            IEnumerable <IndexEntry <T> > entries;

            while (true)
            {
                entries = Search(geohash);
                if (exclude != null && !exclude.Equals(default(T)))
                {
                    entries = entries.Where(entry => !entry.Value.Equals(exclude));
                }
                if (entries.Count() >= minimumHits)
                {
                    break;
                }
                else if (lockPrecision)
                {
                    break;
                }
                else if (geohash.Length == 1)
                {
                    break;
                }
                geohash = _geohasher.Reduce(geohash);
            }

            return(entries, geohash);
        }
コード例 #2
0
        ///<inheritdoc/>
        public (IEnumerable <IndexEntry <T> >, string) Query(string hash, int minimumHits = 1, bool lockPrecision = false, T exclude = default)
        {
            IEnumerable <IndexEntry <T> > entries;

            while (true)
            {
                var trieMapSearchResult = _trieMap.Search(hash);
                entries = trieMapSearchResult.SelectMany(sr => sr.IndexEntries);                 // Each entry in the map is a list, so we flatten the result
                int hitCount;
                if (exclude != null && !exclude.Equals(default(T)))
                {
                    entries = entries.Where(entry => !entry.Value.Equals(exclude));
                }
                hitCount = entries.Count();
                if (hitCount >= minimumHits)
                {
                    break;
                }
                else if (lockPrecision)
                {
                    break;
                }
                else if (hash.Length == 1)
                {
                    break;
                }
                hash = _geohasher.Reduce(hash);
            }

            return(entries, hash);
        }