Example #1
0
        /**
         * Specialized version of GetIntersection() that gets the intersection of a
         * cell union with the given cell id. This can be useful for "splitting" a
         * cell union into chunks.
         */

        public void GetIntersection(S2CellUnion x, S2CellId id)
        {
            // assert (x != this);
            _cellIds.Clear();
            if (x.Contains(id))
            {
                _cellIds.Add(id);
            }
            else
            {
                var pos = x._cellIds.BinarySearch(id.RangeMin);

                if (pos < 0)
                {
                    pos = -pos - 1;
                }

                var idmax = id.RangeMax;
                var size  = x._cellIds.Count;
                while (pos < size && x._cellIds[pos] <= idmax)
                {
                    _cellIds.Add(x._cellIds[pos++]);
                }
            }
        }