public void DisplayLocationsForYear(string year) { int.TryParse(year, out int result); if (year.Length == 4 && result != 0) { List <MapLocation> locations; var mh = MapHelper.Instance; if (result == 9999) { locations = FilterToRelationsIncluded(mh.AllMapLocations); txtLocations.Text = locations.Count() + " Locations in total"; } else { locations = FilterToRelationsIncluded(mh.YearMapLocations(new FactDate(year), yearLimit)); txtLocations.Text = locations.Count() + " Locations in total for year " + year; } txtLocations.Text += " (you may need to zoom out to see them all). Use arrow tool then select icon to view ancestors at location"; clusters.Clear(); foreach (MapLocation loc in locations) { FeatureDataRow row = loc.AddFeatureDataRow(clusters.FactLocations); } if (!mnuKeepZoom.Checked) { Envelope expand = mh.GetExtents(clusters.FactLocations); mapBox1.Map.ZoomToBox(expand); } RefreshClusters(); } }
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; }