public override bool Get(int docId)
            {
                float docX = m_xvals.Get(docId);
                float docY = m_yvals.Get(docId);
                float docZ = m_zvals.Get(docId);

                return(InCircle(docX, docY, docZ, m_targetX, m_targetY, m_targetZ, m_radius));
            }
            public sealed override int NextDoc()
            {
                float x  = m_targetX;
                float xu = x + m_delta;
                float xl = x - m_delta;
                float y  = m_targetY;
                float yu = y + m_delta;
                float yl = y - m_delta;
                float z  = m_targetZ;
                float zu = z + m_delta;
                float zl = z - m_delta;

                int docid = m_doc;

                while (++docid < m_maxDoc)
                {
                    float docX = m_xvals.Get(docid);
                    if (docX > xu || docX < xl)
                    {
                        continue;
                    }

                    float docY = m_yvals.Get(docid);
                    if (docY > yu || docY < yl)
                    {
                        continue;
                    }

                    float docZ = m_zvals.Get(docid);
                    if (docZ > zu || docZ < zl)
                    {
                        continue;
                    }

                    if (GeoFacetFilter.InCircle(docX, docY, docZ, m_targetX, m_targetY, m_targetZ, m_radius))
                    {
                        m_doc = docid;
                        return(m_doc);
                    }
                }
                m_doc = DocIdSetIterator.NO_MORE_DOCS;
                return(m_doc);
            }
        public override string[] GetFieldValues(BoboSegmentReader reader, int id)
        {
            GeoFacetData   dataCache = GetFacetData <GeoFacetData>(reader);
            BigSingleArray xvals     = dataCache.xValArray;
            BigSingleArray yvals     = dataCache.yValArray;
            BigSingleArray zvals     = dataCache.zValArray;

            float xvalue = xvals.Get(id);
            float yvalue = yvals.Get(id);
            float zvalue = zvals.Get(id);
            float lat    = GeoMatchUtil.GetMatchLatDegreesFromXYZCoords(xvalue, yvalue, zvalue);
            float lon    = GeoMatchUtil.GetMatchLonDegreesFromXYZCoords(xvalue, yvalue, zvalue);

            string[] fieldValues = new string[2];
            fieldValues[0] = Convert.ToString(lat);
            fieldValues[1] = Convert.ToString(lon);
            return(fieldValues);
        }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="docid">The docid for which the facet counts are to be calculated</param>
        public virtual void Collect(int docid)
        {
            float docX = m_xvals.Get(docid);
            float docY = m_yvals.Get(docid);
            float docZ = m_zvals.Get(docid);

            float radius, targetX, targetY, targetZ, delta;
            float xu, xl, yu, yl, zu, zl;
            int   countIndex = -1;

            foreach (GeoRange range in m_ranges)
            {
                // the countIndex for the count array should increment with the range index of the _ranges array
                countIndex++;
                if (m_miles)
                {
                    radius = GeoMatchUtil.GetMilesRadiusCosine(range.Rad);
                }
                else
                {
                    radius = GeoMatchUtil.GetKMRadiusCosine(range.Rad);
                }

                float[] coords = GeoMatchUtil.GeoMatchCoordsFromDegrees(range.Lat, range.Lon);
                targetX = coords[0];
                targetY = coords[1];
                targetZ = coords[2];

                if (m_miles)
                {
                    delta = (float)(range.Rad / GeoMatchUtil.EARTH_RADIUS_MILES);
                }
                else
                {
                    delta = (float)(range.Rad / GeoMatchUtil.EARTH_RADIUS_KM);
                }

                xu = targetX + delta;
                xl = targetX - delta;

                // try to see if the range checks can short circuit the actual inCircle check
                if (docX > xu || docX < xl)
                {
                    continue;
                }

                yu = targetY + delta;
                yl = targetY - delta;

                if (docY > yu || docY < yl)
                {
                    continue;
                }

                zu = targetZ + delta;
                zl = targetZ - delta;

                if (docZ > zu || docZ < zl)
                {
                    continue;
                }

                if (GeoFacetFilter.InCircle(docX, docY, docZ, targetX, targetY, targetZ, radius))
                {
                    // if the lat, lon values of this docid match the current user-specified range, then increment the
                    // appropriate count[] value
                    m_count.Add(countIndex, m_count.Get(countIndex) + 1);
                    // do not break here, since one document could lie in multiple user-specified ranges
                }
            }
        }