Esempio n. 1
0
        void BuildMap()
        {
            if (isloading)
            {
                return;
            }
            Cursor = Cursors.WaitCursor;
            clusters.Clear();
            dgFacts.DataSource = null;
            List <IDisplayFact> displayFacts            = new List <IDisplayFact>();
            List <Individual>   list                    = new List <Individual>();
            List <Tuple <FactLocation, int> > locations = new List <Tuple <FactLocation, int> >();

            foreach (TreeNode node in tvPlaces.SelectedNodes)
            {
                Tuple <FactLocation, int> location = new Tuple <FactLocation, int>((FactLocation)node.Tag, node.Level);
                list.AddRange(ft.GetIndividualsAtLocation(location.Item1, location.Item2));
                locations.Add(location);
            }
            if (list.Count == 0)
            {
                Cursor = Cursors.Default;
                RefreshClusters();
                return;
            }
            int count = 0;

            progressbar.Visible = true;
            progressbar.Maximum = list.Count;
            foreach (Individual ind in list)
            {
                foreach (DisplayFact dispfact in ind.AllGeocodedFacts)
                {
                    foreach (Tuple <FactLocation, int> location in locations)
                    {
                        if (dispfact.Location.CompareTo(location.Item1, location.Item2) == 0)
                        {
                            displayFacts.Add(dispfact);
                            MapLocation loc = new MapLocation(ind, dispfact.Fact, dispfact.FactDate);
                            loc.AddFeatureDataRow(clusters.FactLocations);
                            break;
                        }
                    }
                }
                progressbar.Value = ++count;
                txtCount.Text     = $"Processed {count} Individuals from list of {list.Count}";
                Application.DoEvents();
            }
            progressbar.Visible = false;
            txtCount.Text       = $"Downloading map tiles and computing clusters for {displayFacts.Count} facts. Please wait";
            Application.DoEvents();
            dgFacts.DataSource = new SortableBindingList <IDisplayFact>(displayFacts);

            Envelope expand = mh.GetExtents(clusters.FactLocations);

            mapBox1.Map.ZoomToBox(expand);
            mapBox1.ActiveTool = SharpMap.Forms.MapBox.Tools.Pan;
            RefreshClusters();
            txtCount.Text = $"{dgFacts.RowCount} Geolocated fact(s) displayed";
            Cursor        = Cursors.Default;
        }