public void RTree_Stress_Test()
        {
            var nodeCount      = 10000;
            var randomPolygons = new HashSet <Polygon>();

            for (int i = 0; i < nodeCount; i++)
            {
                randomPolygons.Add(getRandomPointOrPolygon());
            }

            var order = 5;
            var tree  = new RTree(order);

            foreach (var polygon in randomPolygons)
            {
                tree.Insert(polygon);
            }

            //IEnumerable test
            Assert.AreEqual(tree.Count, tree.Count());

            foreach (var polygon in randomPolygons)
            {
                tree.Delete(polygon);
            }
        }
        public void RTree_Deletion_Test()
        {
            var nodeCount      = 1000;
            var randomPolygons = new System.Collections.Generic.HashSet <Polygon>();

            for (int i = 0; i < nodeCount; i++)
            {
                randomPolygons.Add(getRandomPointOrPolygon());
            }
            var order = 5;
            var tree  = new RTree(order);

            foreach (var polygon in randomPolygons)
            {
                tree.Insert(polygon);
            }

            int j = randomPolygons.Count;

            foreach (var polygon in randomPolygons)
            {
                tree.Delete(polygon);
                Assert.IsFalse(tree.Exists(polygon));

                j--;

                if (j > 0)
                {
                    var actualMaxHeight = tree.Root.Height;
                    Assert.AreEqual(verifyHeightUniformityAndReturnHeight(tree.Root, order), actualMaxHeight);
                    Assert.AreEqual(j, tree.Count);
                }
            }
        }
        /// <summary>
        /// Removes the item in the specified tile from the game, and updates the indexes.
        /// </summary>
        private static void RemoveItem(Tile tile, int dimension)
        {
            int     itemID = tile.Item.ItemID;
            Point2D l      = tile.MapLocation;
            Chunk   chunk  = World.Data.World.GetChunkByTile(dimension, l.X, l.Y);

            if (chunk.Items.ContainsKey(itemID))
            {
                RTree <Point2D> result  = chunk.Items[itemID];
                bool            success = result.Delete(new Rectangle(l.X, l.Y, l.X, l.Y), new Point2D(l.X, l.Y));

                if (!success)
                {
                    throw new RegistryDeletionException("Failed to delete an item!");
                }

                if (result.Count == 0)
                {
                    RTree <Point2D> chunksContaining = World.Data.World.Dimensions[dimension].Items.ItemIDToChunk[itemID];
                    bool            succeed          = chunksContaining.Delete(new Rectangle(chunk.ChunkLocation.X, chunk.ChunkLocation.Y, chunk.ChunkLocation.X, chunk.ChunkLocation.Y), new Point2D(chunk.ChunkLocation.X, chunk.ChunkLocation.Y));

                    if (!succeed)
                    {
                        throw new RegistryDeletionException("Failed to delete a chunk containing an item!");
                    }
                }
                tile.Item = null;
            }
        }
        public void TestMultithreading()
        {
            var instance = new RTree <string>();

            Parallel.For(0, 100, i => {
                instance.Add(new Rectangle(0, 0, 0, 0, 0, 0), $"Origin-{Guid.NewGuid()}");
                instance.Add(new Rectangle(1, 1, 1, 1, 1, 1), $"Box1-{Guid.NewGuid()}");

                var rect_to_delete_name = $"Box 2-3-{Guid.NewGuid()}";
                instance.Add(new Rectangle(2, 2, 3, 3, 2, 3), rect_to_delete_name);
                instance.Add(new Rectangle(2, 2, 3, 3, 2, 3), $"Box 2-3-{Guid.NewGuid()}");

                var instancelist = instance.Contains(new Rectangle(-1, -1, 2, 2, -1, 2));
                Assert.IsTrue(instancelist.Count() > 0);

                var intersectlist = instance.Intersects(new Rectangle(3, 3, 5, 5, 3, 5));
                Assert.IsTrue(intersectlist.Count() > 1);
                Assert.IsTrue(intersectlist[0].StartsWith("Box 2-3"));

                var nearestlist = instance.Nearest(new Point(5, 5, 5), 10);

                Assert.IsTrue(nearestlist[0].StartsWith("Box 2-3"));

                instance.Delete(new Rectangle(2, 2, 3, 3, 2, 3), rect_to_delete_name);

                nearestlist = instance.Nearest(new Point(5, 5, 5), 10);

                Assert.IsTrue(nearestlist.Count() > 0);

                Assert.IsTrue(nearestlist[0].StartsWith("Box 2"));
            });
        }
示例#5
0
 /// <summary>
 /// Removes the row (feature) from the table
 /// </summary>
 /// <param name="row"></param>
 public void RemoveRow(FdoFeature row)
 {
     base.Rows.Remove(row);
     if (row.BoundingBox != null)
     {
         _tree.Delete(row.BoundingBox, row);
     }
 }
示例#6
0
        public void NonExistentItemCanBeDeleted()
        {
            var tree = new RTree <Point>(maxEntries: 4);

            tree.BulkLoad(points);

            tree.Delete(new Point(13, 13, 13, 13));
            Assert.AreEqual(points.Length, tree.Count);
        }
示例#7
0
        public void BasicRemoveTest()
        {
            var tree = new RTree <Point>(maxEntries: 4);

            tree.BulkLoad(points);

            var len = points.Length;

            tree.Delete(points[0]);
            tree.Delete(points[1]);
            tree.Delete(points[2]);

            tree.Delete(points[len - 1]);
            tree.Delete(points[len - 2]);
            tree.Delete(points[len - 3]);

            var shouldFindPoints = points
                                   .Skip(3).Take(len - 6)
                                   .OrderBy(x => x)
                                   .ToList();
            var foundPoints = tree.Search()
                              .OrderBy(x => x)
                              .ToList();

            Assert.AreEqual(shouldFindPoints, foundPoints);
            Assert.AreEqual(shouldFindPoints.Count, tree.Count);
            Assert.AreEqual(
                shouldFindPoints.Aggregate(Envelope.EmptyBounds, (e, p) => e.Extend(p.Envelope)),
                tree.Envelope);
        }
示例#8
0
        /// <summary>
        /// Удаление здания
        /// </summary>
        private void Building_Erased(object sender, ObjectErasedEventArgs e)
        {
            // Определение удаленного здания
            var building = FindBuildingByEnt(e.DBObject.Id);

            if (building != null)
            {
                Buildings.Remove(building);
                building.Dispose();
                var r = GetBuildingRectangle(building);
                treeBuildings.Delete(r, building);

                if (IsEventsOn)
                {
                    BuildingErased?.Invoke(this, building);
                }
            }
        }
示例#9
0
        public void BulkLoadAfterDeleteTest2()
        {
            var pts       = GetPoints(20);
            var ptsDelete = pts.Take(4);
            var tree      = new RTree <Point>(maxEntries: 4);

            tree.BulkLoad(pts);

            foreach (var item in ptsDelete)
            {
                tree.Delete(item);
            }

            tree.BulkLoad(ptsDelete);

            Assert.AreEqual(pts.Count, tree.Search().Count);
            Assert.AreEqual(pts.OrderBy(x => x).ToList(), tree.Search().OrderBy(x => x).ToList());
        }
示例#10
0
        public void AdditionalRemoveTest()
        {
            var tree      = new RTree <Point>();
            var numDelete = 18;

            foreach (var p in points)
            {
                tree.Insert(p);
            }

            foreach (var p in points.Take(numDelete))
            {
                tree.Delete(p);
            }

            Assert.AreEqual(points.Length - numDelete, tree.Count);
            Assert.AreEqual(points.Skip(numDelete).OrderBy(x => x), tree.Search().OrderBy(x => x));
        }
        public void RTree_Stress_Test()
        {
            var nodeCount      = 10000;
            var randomPolygons = new System.Collections.Generic.HashSet <Polygon>();

            for (int i = 0; i < nodeCount; i++)
            {
                randomPolygons.Add(getRandomPointOrPolygon());
            }

            var order = 5;
            var tree  = new RTree(order);

            foreach (var polygon in randomPolygons)
            {
                tree.Insert(polygon);
            }

            foreach (var polygon in randomPolygons)
            {
                tree.Delete(polygon);
            }
        }
示例#12
0
        public void InsertAfterDeleteTest1()
        {
            var pts       = GetPoints(20);
            var ptsDelete = pts.Take(18);
            var tree      = new RTree <Point>(maxEntries: 4);

            foreach (var item in pts)
            {
                tree.Insert(item);
            }

            foreach (var item in ptsDelete)
            {
                tree.Delete(item);
            }

            foreach (var item in ptsDelete)
            {
                tree.Insert(item);
            }

            Assert.AreEqual(pts.Count, tree.Search().Count);
            Assert.AreEqual(pts.OrderBy(x => x).ToList(), tree.Search().OrderBy(x => x).ToList());
        }
示例#13
0
        private double K_LOWER_PERCENT = (5 / 100.0); // note: double type

        private void doStream(String file_name, String algorithm, List <double> result, List <double> norm_buffer, List <double> data_to_calc_w, List <double> stream_data, int N_LENGTH, int W_LENGTH, List <double> raw_buffer, double threshold_mean, double threshold_std, double threshold_sim, int R, int maxEntry, int minEntry, int period)
        {
            bool is_the_first_time = true;//control running HOTSAX for the first time
            int  raw_buffer_len    = raw_buffer.Count;
            int  norm_buffer_len   = norm_buffer.Count;
            //get last raw segment:
            //List<double> last_raw_segment = raw_buffer.GetRange(raw_buffer_len - N_LENGTH, N_LENGTH);

            //store index of the limited searching space (in case (b)):
            List <int> candidate_list = new List <int>();

            int index_stream    = 0; //control the stream data point
            int index_table     = 0;
            int i_b             = 0; //calc number of cases (b).
            int data_calc_w_len = data_to_calc_w.Count;

            //store result from HOTSAX algorithm:
            //List<double> result
            //result[0]: dist
            //result[1]: loc

            double next_data_point;
            double currDist;

            System.Diagnostics.Stopwatch watch2;; ///calc execution time
            long elapsedMs2 = 0;

            double        small_match_dist = 0;
            List <double> first_segment;

            double new_norm_point;

            AugmentedTrie            tree;
            Dictionary <string, int> count_table;
            Dictionary <int, string> total_table;

            count_table = new Dictionary <string, int>();
            total_table = new Dictionary <int, string>();

            //Making the root node:
            HOTSAX.TreeNode root = new HOTSAX.TreeNode('R');

            //init the path (to print the tree later)
            List <char> path = new List <char>();

            // Making the augmented tree:
            tree = new AugmentedTrie(root, path);

            // Squeezer
            List <int> cluster_belong         = new List <int>();
            List <Cluster_Squeezer> b_cluster = new List <Cluster_Squeezer>();
            List <int> lCluster_NonMember     = new List <int>();

            // Bounding_Box
            int         this_id_item     = int.MinValue;
            List <int>  this_id_itemList = new List <int>();
            RTree <int> this_RTree       = new RTree <int>(maxEntry, minEntry);
            List <BoundingBox.Rectangle> this_recList = new List <BoundingBox.Rectangle>();
            double this_best_so_far_dist = -Constants.INFINITE;
            double this_best_so_far_loc  = -1;

            BoundingBox.Rectangle new_rec;

            // Useless variable to pass parameter
            int        dumb      = 0;
            List <int> dumb_list = new List <int>();
            List <BoundingBox.Rectangle> dumb_rectlist = new List <BoundingBox.Rectangle>();
            RTree <int> dumb_rtree = new RTree <int>(maxEntry, minEntry);

            // Sanchez_method
            double this_best_so_far_dist_TheMostDiscord = -Constants.INFINITE;


            double old_mean = MathFuncs.CalcMean(raw_buffer);
            double old_std = MathFuncs.CalcStd(raw_buffer, old_mean);
            double new_mean, new_std;

            List <double> result_dist = new List <double>();
            List <double> result_loc  = new List <double>();

            var watch   = System.Diagnostics.Stopwatch.StartNew();///calc execution time
            int num_nor = 0;

            while (true)
            {
                manualResetEvent.WaitOne(Timeout.Infinite);//help for PAUSE, RESUME button

                if (is_the_first_time)
                {
                    watch2 = System.Diagnostics.Stopwatch.StartNew();///calc execution time
                    switch (algorithm)
                    {
                    case "HOTSAX_Squeezer_Stream":
                        result = BitClusterDiscord.squeezer(ref lCluster_NonMember, ref cluster_belong, ref b_cluster, norm_buffer, N_LENGTH, W_LENGTH, threshold_sim, BitClusterDiscord.PAA);                            Console.WriteLine("Case 1");
                        break;

                    case "BFHS":
                    case "HOTSAX_Stream":
                        result = HOTSAX.HOTSAX.originalHOTSAX(0, norm_buffer, N_LENGTH, W_LENGTH,
                                                              ref tree, ref count_table, ref total_table, true);
                        break;

                    case "Bounding_Box":
                        result = BoundingBox.BoundingBoxDiscordDiscovery.RunOfflineMinDist(raw_buffer, N_LENGTH, maxEntry, minEntry, R, W_LENGTH, ref this_id_item, ref this_id_itemList, ref this_recList, ref this_RTree, true);
                        this_best_so_far_dist = result[0];
                        this_best_so_far_loc  = result[1];
                        break;

                    case "Sanchez_Method":
                        result = BoundingBox.BoundingBoxDiscordDiscovery.RunOfflineMinDist(raw_buffer, N_LENGTH, maxEntry, minEntry, R, W_LENGTH, ref this_id_item, ref this_id_itemList, ref this_recList, ref this_RTree, true);
                        this_best_so_far_dist_TheMostDiscord = result[0];
                        result = new List <double> {
                            -1, -1
                        };
                        break;
                    }
                    is_the_first_time = false;
                    watch2.Stop();
                    elapsedMs2 = watch2.ElapsedMilliseconds;
                    //print through console
                    Console.WriteLine("\n\t best_so_far_dist = " + result.ElementAt(0) +
                                      "\n\t best_so_far_loc = " + result.ElementAt(1) +
                                      "\n\t execution_time = " + elapsedMs2);
                    Console.WriteLine("----------------- finished i = {0}--------------- \n\n", index_stream - 1);
                    Console.WriteLine("Finished the first call.");
                    if (chart_timeSeries.IsHandleCreated)
                    {
                        try
                        {
                            // call updateChart fucntion in GUI thread by chart thread

                            if (algorithm == "Bounding_Box" || algorithm == "Sanchez_Method")
                            {
                                this.Invoke((MethodInvoker) delegate { updateChart(raw_buffer, (int)(result[1]), N_LENGTH, index_stream, elapsedMs2); });
                            }
                            else
                            {
                                this.Invoke((MethodInvoker) delegate { updateChart(norm_buffer, (int)(result[1]), N_LENGTH, index_stream, elapsedMs2); });
                            }
                        }
                        catch
                        { }
                    }
                }
                else
                {
                    if (index_stream >= stream_data.Count)
                    {
                        watch.Stop();//stop timer
                        var elapsedMs = watch.ElapsedMilliseconds;
                        Console.WriteLine("Streaming is Done in " + elapsedMs + ".\nKeep going...Please wait");
                        // Write File
                        string[] all_dist = result_dist.Select(dist => dist.ToString()).ToArray();
                        string[] all_loc  = result_loc.Select(loc => loc.ToString()).ToArray();

                        var    data_name = System.IO.Path.GetFileNameWithoutExtension(file_name);
                        var    extension = System.IO.Path.GetExtension(file_name);
                        string newPath   = "Output\\" + data_name + "\\" + algorithm;
                        System.IO.Directory.CreateDirectory(newPath);
                        System.IO.File.WriteAllLines(newPath + "\\dist" + extension, all_dist);
                        System.IO.File.WriteAllLines(newPath + "\\loc" + extension, all_loc);
                        using (System.IO.StreamWriter file =
                                   new System.IO.StreamWriter(newPath + "\\time" + extension, false))
                        {
                            file.WriteLine(elapsedMs);
                        }
                        this.txt_speed.Text = "0";
                        Statistical_Form statistical_form = new Statistical_Form(algorithm, file_name, result_loc, result_dist, elapsedMs);
                        System.Windows.Forms.MessageBox.Show("stream_data ran out of points");
                        Console.WriteLine("num norm: " + num_nor);
                        return;
                    }

                    //get the next data point:
                    next_data_point = stream_data[index_stream];

                    new_mean = MathFuncs.CalcNewMean(old_mean, raw_buffer_len, raw_buffer[0], next_data_point);

                    //store the last subsequence of the buffer for Bounding Box and Sanchez algorithms:
                    List <double> last_sub = raw_buffer.GetRange(raw_buffer.Count - N_LENGTH, N_LENGTH);

                    //get the first sub before update the buffer (help to find the small match in Liu's method)
                    List <double> first_sub = raw_buffer.GetRange(0, N_LENGTH);

                    //update raw_buffer:
                    raw_buffer.Add(next_data_point);
                    raw_buffer.RemoveAt(0);

                    new_std = MathFuncs.CalcStd(raw_buffer, new_mean);
                    watch2  = System.Diagnostics.Stopwatch.StartNew();///calc execution time

                    switch (algorithm)
                    {
                    case "HOTSAX_Squeezer_Stream":
                    case "BFHS":
                    case "HOTSAX_Stream":
                        if ((Math.Abs(new_mean - old_mean) <= threshold_mean) && (Math.Abs(new_std - old_std) <= threshold_std))
                        {
                            new_norm_point = (next_data_point - old_mean) / old_std;

                            index_table++;

                            norm_buffer.Add(new_norm_point);

                            //calc 'currDist':
                            currDist = MathFuncs.EuDistance(norm_buffer.GetRange((int)result[1], N_LENGTH), norm_buffer.GetRange(norm_buffer.Count - N_LENGTH, N_LENGTH));


                            //if the case (a): Modify the Tree, Tables:
                            if (currDist < result[0] || (int)(result[1]) == 0 || algorithm == "BFHS")
                            {
                                Console.WriteLine("--- Running case (a)... ---");

                                if (algorithm == "HOTSAX_Squeezer_Stream")
                                {
                                    result = BitClusterDiscord.squeezer(ref lCluster_NonMember, ref cluster_belong, ref b_cluster, norm_buffer.Select(point => point).ToList(), N_LENGTH, W_LENGTH, threshold_sim, BitClusterDiscord.PAA, index_table, false);
                                    //update buffer:
                                    norm_buffer.RemoveAt(0);
                                    Console.WriteLine("B_cluster.Count: " + b_cluster.Count.ToString());
                                }
                                else
                                {
                                    //call the original HOTSAX ver3:
                                    result = HOTSAX.HOTSAX.originalHOTSAX(index_table, norm_buffer,
                                                                          N_LENGTH, W_LENGTH, ref tree, ref count_table, ref total_table);
                                }
                            }
                            else     // case (b), we can limit candidate_list:
                            {
                                Console.WriteLine("--------------- Running case (b)... -----------------");
                                /* Find the candidate_list:  */
                                candidate_list.Clear();     //reset the list


                                //The local discord at time t:
                                candidate_list.Add((int)(result[1]) - 1);

                                //The subsequence (m-n+1, n)(t+1):
                                candidate_list.Add(norm_buffer_len - N_LENGTH);

                                //The small match of subsequence (1, n)(t):
                                first_segment = norm_buffer.GetRange(0, N_LENGTH);
                                for (int j = N_LENGTH; j <= norm_buffer_len - N_LENGTH; j++)
                                {
                                    small_match_dist = MathFuncs.EuDistance(norm_buffer.GetRange(j, N_LENGTH), first_segment);
                                    if (small_match_dist < result[0])
                                    {
                                        if ((int)(result[1]) != j)
                                        {
                                            candidate_list.Add(j - 1);
                                        }
                                    }
                                }

                                if (algorithm == "HOTSAX_Squeezer_Stream")
                                {
                                    result = BitClusterDiscord.squeezerAgain(ref lCluster_NonMember, candidate_list, index_table, ref cluster_belong, ref b_cluster, norm_buffer.Select(point => point).ToList(), N_LENGTH, W_LENGTH, threshold_sim, BitClusterDiscord.PAA);
                                    //update buffer:
                                    norm_buffer.RemoveAt(0);
                                    Console.WriteLine("B_cluster.Count: " + b_cluster.Count.ToString());
                                }
                                else
                                {
                                    //update buffer:
                                    norm_buffer.RemoveAt(0);

                                    //searching on candidates;
                                    result = HOTSAX.HOTSAX.candidateHOTSAX(candidate_list, index_table, norm_buffer,
                                                                           N_LENGTH, W_LENGTH, ref tree, ref count_table, ref total_table);
                                }


                                i_b++;    //count number of cases (b) - just for testing

                                Console.WriteLine("len(candidate_list) = {0}, Number of cases (b) is {1}/{2}", candidate_list.Count, i_b, index_stream);
                            }    //end else - case (b)
                        }
                        else
                        {
                            Console.WriteLine("--------------- Normalizing buffer ... -----------------");
                            num_nor++;
                            index_table    = 0;
                            norm_buffer    = MathFuncs.zScoreNorm(raw_buffer, raw_buffer_len);
                            count_table    = new Dictionary <string, int>();
                            total_table    = new Dictionary <int, string>();
                            cluster_belong = new List <int>();
                            b_cluster      = new List <Cluster_Squeezer>();

                            //Making the root node:
                            root = new HOTSAX.TreeNode('R');

                            //init the path (to print the tree later)
                            path = new List <char>();

                            // Making the augmented tree:
                            tree = new AugmentedTrie(root, path);

                            if (algorithm == "HOTSAX_Squeezer_Stream")
                            {
                                result = BitClusterDiscord.squeezer(ref lCluster_NonMember, ref cluster_belong, ref b_cluster, norm_buffer, N_LENGTH, W_LENGTH, threshold_sim, BitClusterDiscord.PAA);
                            }
                            else
                            {
                                result = HOTSAX.HOTSAX.originalHOTSAX(0, norm_buffer, N_LENGTH, W_LENGTH,
                                                                      ref tree, ref count_table, ref total_table, true);
                            }
                            old_std  = new_std;
                            old_mean = new_mean;
                        }
                        break;

                    case "Bounding_Box":
                        //update last_sub at time t to get new_sub at time (t+1):
                        last_sub.Add(next_data_point);
                        last_sub.RemoveAt(0);
                        List <double> new_sub = last_sub;    // the same object

                        // Insert the new entry into the tree:
                        this_id_item++;

                        // Add the new rec to the tree:
                        new_rec = new BoundingBox.Rectangle(Utils.MathFuncs.PAA_Lower(new_sub, W_LENGTH, R).ToArray(), Utils.MathFuncs.PAA_Upper(new_sub, W_LENGTH, R).ToArray(), raw_buffer.Count - N_LENGTH + 1 + index_stream);
                        this_RTree.Add(new_rec, this_id_item);
                        this_recList.Add(new_rec);
                        this_id_itemList.Add(this_id_item);

                        //remove the oldest entry:
                        this_RTree.Delete(this_recList[index_stream], this_id_itemList[index_stream]);

                        result = BoundingBoxDiscordDiscovery.RunOnline_LiuMethod_edited(raw_buffer, index_stream, first_sub, this_RTree, this_best_so_far_dist, (int)this_best_so_far_loc, N_LENGTH, W_LENGTH);
                        this_best_so_far_dist = result[0];
                        this_best_so_far_loc  = result[1];

                        break;

                    case "Sanchez_Method":
                        //update last_sub at time t to get new_sub at time (t+1):
                        last_sub.Add(next_data_point);
                        last_sub.RemoveAt(0);
                        new_sub = last_sub;     // the same object

                        // Insert the new entry into the tree:
                        this_id_item++;

                        // Add the new rec to the tree:
                        new_rec = new BoundingBox.Rectangle(Utils.MathFuncs.PAA_Lower(new_sub, W_LENGTH, R).ToArray(), Utils.MathFuncs.PAA_Upper(new_sub, W_LENGTH, R).ToArray(), raw_buffer.Count - N_LENGTH + 1 + index_stream);
                        this_RTree.Add(new_rec, this_id_item);
                        this_recList.Add(new_rec);
                        this_id_itemList.Add(this_id_item);

                        //remove the oldest entry:
                        this_RTree.Delete(this_recList[index_stream], this_id_itemList[index_stream]);

                        result = BoundingBoxDiscordDiscovery.NewOnlineAlgorithm(raw_buffer, 2 * period, index_stream, period, new_sub, this_RTree, N_LENGTH, W_LENGTH, R, maxEntry, minEntry, ref this_best_so_far_dist_TheMostDiscord);

                        break;
                    }

                    watch2.Stop(); //stop timer
                    elapsedMs2 = watch2.ElapsedMilliseconds;
                    //print through console
                    Console.WriteLine("\n\t best_so_far_dist = " + result.ElementAt(0) +
                                      "\n\t best_so_far_loc = " + result.ElementAt(1) +
                                      "\n\t execution_time = " + elapsedMs2);
                    Console.WriteLine("----------------- finished i = {0}--------------- \n\n", index_stream);

                    index_stream++;// make 'index' increase by 1 to get the next data point
                }//end else


                if (chart_timeSeries.IsHandleCreated)
                {
                    try
                    {
                        // call updateChart fucntion in GUI thread by chart thread

                        if (algorithm == "Bounding_Box" || algorithm == "Sanchez_Method")
                        {
                            this.Invoke((MethodInvoker) delegate { updateChart(raw_buffer, (int)(result[1]), N_LENGTH, index_stream, elapsedMs2); });
                        }
                        else
                        {
                            this.Invoke((MethodInvoker) delegate { updateChart(norm_buffer, (int)(result[1]), N_LENGTH, index_stream, elapsedMs2); });
                        }
                    }
                    catch
                    { }
                }


                // Store result
                result_dist.Add(result.ElementAt(0));
                result_loc.Add(result.ElementAt(1));
                //Thread.Sleep(2000);
            }
        }
示例#14
0
        public void RemoveFromRTree(GameInstance i, RTree <int> tree)
        {
            var rect = GetInstanceRTreeRectangle(i);

            tree.Delete(rect, i.Id);
        }