public void ClearPopUps()
 {
     lock (m_QuadTree)
     {
         m_QuadTree = new Quadtree();
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Snaps the points to the network coverage, given the tolerance. Existing locations/values will be cleared only
        /// when there are new points mapped to that branch.
        /// </summary>
        /// <param name="pointValuePairs"></param>
        /// <param name="networkCoverage"></param>
        /// <param name="tolerance"></param>
        public static void SnapToCoverage(IEnumerable<Tuple<IPoint, double>> pointValuePairs,
                                          INetworkCoverage networkCoverage, double tolerance)
        {
            var tree = new Quadtree();
            networkCoverage.Network.Branches.ForEach(b => tree.Insert(b.Geometry.EnvelopeInternal, b));
            
            // match points to branch buffers
            var locations = new List<Tuple<INetworkLocation, double>>();
            foreach (var pointValue in pointValuePairs)
            {
                var envelope = pointValue.Item1.EnvelopeInternal;
                envelope.ExpandBy(tolerance);
                var branches = tree.Query(envelope).Cast<IBranch>();

                var location = MapPointToClosestBranch(pointValue.Item1, branches, tolerance);
                if (location != null)
                {
                    locations.Add(new Tuple<INetworkLocation, double>(location, pointValue.Item2));
                }
            }

            // remove values for all branches that have new values imported
            var branchesToClear = locations.Select(l => l.Item1.Branch).Distinct();
            branchesToClear.ForEach(b => NetworkHelper.ClearLocations(networkCoverage, b));

            // add new values/locations to coverage
            locations.ForEach(l => networkCoverage[l.Item1] = l.Item2);
        }
        /// <summary>
        /// 
        /// </summary>
        private void BuildQuadtree()
        {
            quadtree = new Quadtree();

            for (int i = 0; i < rings.Count; i++)
            {
                ILinearRing ring = (ILinearRing) rings[i];
                Envelope env = (Envelope) ring.EnvelopeInternal;
                quadtree.Insert(env, ring);
            }
        }