コード例 #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="xvals">array of x coordinate values for docid</param>
 /// <param name="yvals">array of y coordinate values for docid</param>
 /// <param name="zvals">array of z coordinate values for docid</param>
 /// <param name="lat">target latitude</param>
 /// <param name="lon">target longitude</param>
 /// <param name="radius">target radius</param>
 /// <param name="maxdoc">max doc in the docid set</param>
 /// <param name="miles">variable to specify if the geo distance calculations are in miles.
 /// False indicates distance calculation is in kilometers</param>
 internal GeoDocIdSet(BigSingleArray xvals, BigSingleArray yvals, BigSingleArray zvals, float lat, float lon,
                      float radius, int maxdoc, bool miles)
 {
     m_xvals = xvals;
     m_yvals = yvals;
     m_zvals = zvals;
     m_miles = miles;
     if (m_miles)
     {
         m_radius = GeoMatchUtil.GetMilesRadiusCosine(radius);
     }
     else
     {
         m_radius = GeoMatchUtil.GetKMRadiusCosine(radius);
     }
     float[] coords = GeoMatchUtil.GeoMatchCoordsFromDegrees(lat, lon);
     m_targetX = coords[0];
     m_targetY = coords[1];
     m_targetZ = coords[2];
     if (m_miles)
     {
         m_delta = (float)(radius / GeoMatchUtil.EARTH_RADIUS_MILES);
     }
     else
     {
         m_delta = (float)(radius / GeoMatchUtil.EARTH_RADIUS_KM);
     }
     m_maxDoc = maxdoc;
 }
コード例 #2
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 = _xvals.Get(docid);
            float docY = _yvals.Get(docid);
            float docZ = _zvals.Get(docid);

            float radius, targetX, targetY, targetZ, delta;
            float xu, xl, yu, yl, zu, zl;
            int countIndex = -1;
            foreach (GeoRange range in _ranges)
            {
                // the countIndex for the count array should increment with the range index of the _ranges array
                countIndex++;
                if (_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 (_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
                    _count.Add(countIndex, _count.Get(countIndex) + 1);
                    // do not break here, since one document could lie in multiple user-specified ranges
                }
            }
        }
コード例 #3
0
        public override string[] GetFieldValues(BoboIndexReader reader, int id)
        {
            GeoFacetData  dataCache = GetFacetData <GeoFacetData>(reader);
            BigFloatArray xvals     = dataCache.xValArray;
            BigFloatArray yvals     = dataCache.yValArray;
            BigFloatArray 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
            public virtual void Load(string latFieldName, string lonFieldName, BoboIndexReader reader)
            {
                if (reader == null)
                {
                    throw new ArgumentNullException("reader object is null");
                }

                FacetDataCache latCache = (FacetDataCache)reader.GetFacetData(latFieldName);
                FacetDataCache lonCache = (FacetDataCache)reader.GetFacetData(lonFieldName);

                int maxDoc = reader.MaxDoc;

                BigFloatArray xVals = this._xValArray;
                BigFloatArray yVals = this._yValArray;
                BigFloatArray zVals = this._zValArray;

                if (xVals == null)
                {
                    xVals = NewInstance(maxDoc);
                }
                else
                {
                    xVals.EnsureCapacity(maxDoc);
                }
                if (yVals == null)
                {
                    yVals = NewInstance(maxDoc);
                }
                else
                {
                    yVals.EnsureCapacity(maxDoc);
                }
                if (zVals == null)
                {
                    zVals = NewInstance(maxDoc);
                }
                else
                {
                    zVals.EnsureCapacity(maxDoc);
                }

                this._xValArray = xVals;
                this._yValArray = yVals;
                this._zValArray = zVals;

                BigSegmentedArray latOrderArray = latCache.OrderArray;
                ITermValueList    latValList    = latCache.ValArray;

                BigSegmentedArray lonOrderArray = lonCache.OrderArray;
                ITermValueList    lonValList    = lonCache.ValArray;

                for (int i = 0; i < maxDoc; ++i)
                {
                    string docLatString = latValList.Get(latOrderArray.Get(i)).Trim();
                    string docLonString = lonValList.Get(lonOrderArray.Get(i)).Trim();

                    float docLat = 0;
                    if (docLatString.Length > 0)
                    {
                        docLat = float.Parse(docLatString);
                    }

                    float docLon = 0;
                    if (docLonString.Length > 0)
                    {
                        docLon = float.Parse(docLonString);
                    }

                    float[] coords = GeoMatchUtil.GeoMatchCoordsFromDegrees(docLat, docLon);
                    _xValArray.Add(i, coords[0]);
                    _yValArray.Add(i, coords[1]);
                    _zValArray.Add(i, coords[2]);
                }
            }