コード例 #1
0
        private void AddTilesIntersectingEnvelopeAt(SpaceFillingCurveConfiguration config, SpaceFillingCurveMonitor monitor, int depth, int maxDepth, SearchEnvelope search, SearchEnvelope currentExtent, CurveRule curve, long left, long right, List <LongRange> results)
        {
            if (right - left == 1)
            {
                long[] coord = NormalizedCoordinateFor(left, _maxLevel);
                if (search.Contains(coord))
                {
                    LongRange current = (results.Count > 0) ? results[results.Count - 1] : null;
                    if (current != null && current.Max == left - 1)
                    {
                        current.ExpandToMax(left);
                    }
                    else
                    {
                        current = new LongRange(left);
                        results.Add(current);
                    }
                    if (monitor != null)
                    {
                        monitor.AddRangeAtDepth(depth);
                        monitor.AddToCoveredArea(currentExtent.Area);
                    }
                }
            }
            else if (search.Intersects(currentExtent))
            {
                double overlap = search.FractionOf(currentExtent);
                if (config.StopAtThisDepth(overlap, depth, maxDepth))
                {
                    // Note that LongRange upper bound is inclusive, hence the '-1' in several places
                    LongRange current = (results.Count > 0) ? results[results.Count - 1] : null;
                    if (current != null && current.Max == left - 1)
                    {
                        current.ExpandToMax(right - 1);
                    }
                    else
                    {
                        current = new LongRange(left, right - 1);
                        results.Add(current);
                    }
                    if (monitor != null)
                    {
                        monitor.AddRangeAtDepth(depth);
                        monitor.AddToCoveredArea(currentExtent.Area);
                    }
                }
                else
                {
                    long width = (right - left) / _quadFactor;
                    for (int i = 0; i < _quadFactor; i++)
                    {
                        int npoint = curve.NpointForIndex(i);

                        SearchEnvelope quadrant = currentExtent.Quadrant(BitValues(npoint));
                        AddTilesIntersectingEnvelopeAt(config, monitor, depth + 1, maxDepth, search, quadrant, curve.ChildAt(i), left + i * width, left + (i + 1) * width, results);
                    }
                }
            }
        }
コード例 #2
0
 internal virtual bool Intersects(SearchEnvelope other)
 {
     for (int dim = 0; dim < _nbrDim; dim++)
     {
         if (this._max[dim] <= other._min[dim] || other._max[dim] <= this._min[dim])
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #3
0
        internal virtual IList <LongRange> GetTilesIntersectingEnvelope(Envelope referenceEnvelope, SpaceFillingCurveConfiguration config, SpaceFillingCurveMonitor monitor)
        {
            SearchEnvelope   search      = new SearchEnvelope(this, referenceEnvelope);
            SearchEnvelope   wholeExtent = new SearchEnvelope(0, this.Width, _nbrDim);
            List <LongRange> results     = new List <LongRange>(config.InitialRangesListCapacity());

            if (monitor != null)
            {
                monitor.RegisterSearchArea(search.Area);
            }

            AddTilesIntersectingEnvelopeAt(config, monitor, 0, config.MaxDepth(referenceEnvelope, this._range, _nbrDim, _maxLevel), search, wholeExtent, RootCurve(), 0, this.ValueWidth, results);
            return(results);
        }
コード例 #4
0
        /// <summary>
        /// Calculates the faction of the overlapping area between {@code this} and {@code} other compared
        /// to the area of {@code this}.
        ///
        /// Must only be called for intersecting envelopes
        /// </summary>
        internal virtual double FractionOf(SearchEnvelope other)
        {
            double fraction = 1.0;

            for (int i = 0; i < _nbrDim; i++)
            {
                long min = Math.Max(this._min[i], other._min[i]);
                long max = Math.Min(this._max[i], other._max[i]);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double innerFraction = (double)(max - min) / (double)(other.max[i] - other.min[i]);
                double innerFraction = ( double )(max - min) / ( double )(other._max[i] - other._min[i]);
                fraction *= innerFraction;
            }
            return(fraction);
        }