Example #1
0
        /**
         * Creates an edge index over the vertices, which by itself takes no time.
         * Then the expected number of queries is used to determine whether brute
         * force lookups are likely to be slower than really creating an index, and if
         * so, we do so. Finally an iterator is returned that can be used to perform
         * edge lookups.
         */

        private S2EdgeIndex.DataEdgeIterator GetEdgeIterator(int expectedQueries)
        {
            if (_index == null)
            {
                _index = new AnonS2EdgeIndex(this);
            }
            _index.PredictAdditionalCalls(expectedQueries);

            return(new S2EdgeIndex.DataEdgeIterator(_index));
        }
Example #2
0
        /**
         * Copy constructor.
         */

        public S2Loop(S2Loop src)
        {
            _numVertices        = src._numVertices;
            _vertices           = (S2Point[])src._vertices.Clone();
            _vertexToIndex      = src._vertexToIndex;
            _index              = src._index;
            _firstLogicalVertex = src._firstLogicalVertex;
            _bound              = src.RectBound;
            _originInside       = src._originInside;
            _depth              = src._depth;
        }
Example #3
0
        /**
         * Like the constructor above, but assumes that the cell's bounding rectangle
         * has been precomputed.
         *
         * @param cell
         * @param bound
         */

        public S2Loop(S2Cell cell, S2LatLngRect bound)
        {
            _bound         = bound;
            _numVertices   = 4;
            _vertices      = new S2Point[_numVertices];
            _vertexToIndex = null;
            _index         = null;
            _depth         = 0;
            for (var i = 0; i < 4; ++i)
            {
                _vertices[i] = cell.GetVertex(i);
            }
            InitOrigin();
            InitFirstLogicalVertex();
        }
Example #4
0
        /**
         * Reverse the order of the loop vertices, effectively complementing the
         * region represented by the loop.
         */

        public void Invert()
        {
            var last = NumVertices - 1;

            for (var i = (last - 1) / 2; i >= 0; --i)
            {
                var t = _vertices[i];
                _vertices[i]        = _vertices[last - i];
                _vertices[last - i] = t;
            }
            _vertexToIndex = null;
            _index         = null;
            _originInside ^= true;
            if (_bound.Lat.Lo > -S2.PiOver2 && _bound.Lat.Hi < S2.PiOver2)
            {
                // The complement of this loop contains both poles.
                _bound = S2LatLngRect.Full;
            }
            else
            {
                InitBound();
            }
            InitFirstLogicalVertex();
        }
 public DataEdgeIterator(S2EdgeIndex edgeIndex)
 {
     this._edgeIndex = edgeIndex;
     _candidates     = new List <int>();
 }