/// <summary>
            /// Static constructor for BigFloatArray.
            /// </summary>
            /// <param name="maxDoc"></param>
            /// <returns></returns>
            public static BigFloatArray NewInstance(int maxDoc)
            {
                BigFloatArray array = new BigFloatArray(maxDoc);

                array.EnsureCapacity(maxDoc);
                return(array);
            }
 /// <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(BigFloatArray xvals, BigFloatArray yvals, BigFloatArray zvals, float lat, float lon,
                      float radius, int maxdoc, bool miles)
 {
     _xvals = xvals;
     _yvals = yvals;
     _zvals = zvals;
     _miles = miles;
     if (_miles)
     {
         _radius = GeoMatchUtil.GetMilesRadiusCosine(radius);
     }
     else
     {
         _radius = GeoMatchUtil.GetKMRadiusCosine(radius);
     }
     float[] coords = GeoMatchUtil.GeoMatchCoordsFromDegrees(lat, lon);
     _targetX = coords[0];
     _targetY = coords[1];
     _targetZ = coords[2];
     if (_miles)
     {
         _delta = (float)(radius / GeoMatchUtil.EARTH_RADIUS_MILES);
     }
     else
     {
         _delta = (float)(radius / GeoMatchUtil.EARTH_RADIUS_KM);
     }
     _maxDoc = maxdoc;
 }
 internal GeoDocIdSetIterator(BigFloatArray xvals, BigFloatArray yvals, BigFloatArray zvals, float targetX, float targetY, float targetZ,
                              float delta, float radiusCosine, int maxdoc)
 {
     _xvals   = xvals;
     _yvals   = yvals;
     _zvals   = zvals;
     _targetX = targetX;
     _targetY = targetY;
     _targetZ = targetZ;
     _delta   = delta;
     _radius  = radiusCosine;
     _maxDoc  = maxdoc;
     _doc     = -1;
 }
        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);
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="name">name of the Geo Facet</param>
 /// <param name="dataCache">The data cache for the Geo Facet</param>
 /// <param name="docBase">the base doc id</param>
 /// <param name="fspec">the facet spec for this facet</param>
 /// <param name="predefinedRanges">List of ranges, where each range looks like &lt;lat, lon: rad&gt;</param>
 /// <param name="miles">variable to specify if the geo distance calculations are in miles. False indicates distance calculation is in kilometers</param>
 public GeoFacetCountCollector(string name, GeoFacetHandler.GeoFacetData dataCache,
     int docBase, FacetSpec fspec, IEnumerable<string> predefinedRanges, bool miles)
 {
     _name = name;
     _dataCache = dataCache;
     _xvals = dataCache.xValArray;
     _yvals = dataCache.yValArray;
     _zvals = dataCache.zValArray;
     _spec = fspec;
     _predefinedRanges = new TermStringList();
     var predefinedTemp = new List<string>(predefinedRanges);
     predefinedTemp.Sort();
     _predefinedRanges.AddAll(predefinedTemp);
     _docBase = docBase;
     _countlength = predefinedTemp.Count;
     _count = new LazyBigIntArray(_countlength);
     _ranges = new GeoRange[predefinedTemp.Count];
     int index = 0;
     foreach (string range in predefinedTemp)
     {
         _ranges[index++] = Parse(range);
     }
     _miles = miles;
 }
            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]);
                }
            }
 /// <summary>
 /// Initializes a new instance of <see cref="T:GeoFacetData"/>.
 /// </summary>
 /// <param name="xvals">
 /// xValArray array, int of size m, each element is the x coordinate value of the
 /// docid (actually BigFloatArray is used instead of int to avoid requiring large
 /// chunks of consecutive heap allocation)
 /// </param>
 /// <param name="yvals">
 /// yValArray array, int of size m, each element is the y coordinate value of the
 /// docid (actually BigFloatArray is used instead of int to avoid requiring large
 /// chunks of consecutive heap allocation)
 /// </param>
 /// <param name="zvals">
 /// zValArray array, int of size m, each element is the z coordinate value of the
 /// docid (actually BigFloatArray is used instead of int to avoid requiring large
 /// chunks of consecutive heap allocation)
 /// </param>
 public GeoFacetData(BigFloatArray xvals, BigFloatArray yvals, BigFloatArray zvals)
 {
     _xValArray = xvals;
     _yValArray = yvals;
     _zValArray = zvals;
 }
 /// <summary>
 /// Initializes a new instance of <see cref="T:GeoFacetData"/>.
 /// </summary>
 public GeoFacetData()
 {
     _xValArray = null;
     _yValArray = null;
     _zValArray = null;
 }