/// <summary> /// Called when there's a new earthquake. Selects the latest earthquake if visible /// and runs the shake animation. /// </summary> /// <param name="latestEarthquake">The latest earthquake.</param> private void OnLatestEarthquakeChanged(EarthQuakeData latestEarthquake) { EarthQuakeViewModel firstEarthquake = EarthQuakes.ElementAtOrDefault(0); if (firstEarthquake != null && latestEarthquake.Equals(firstEarthquake.Model)) { SelectedTime = firstEarthquake.Updated; } OnShake(EventArgs.Empty); }
public static EarthQuakes ProcessEarthQuakes(ShapefileConverter shapefile) { var earthQuakes = new EarthQuakes(); foreach (ShapefileRecord record in shapefile) { var item = new EarthQuakeData(); if (record.Fields != null) { // get geo-location from shape file (SHP) //location.Longitude = record.Points[0][0].X; //location.Latitude = record.Points[0][0].Y; // get data about a location from database file (DBF) //if (record.Fields.ContainsKey("lon")) item.Longitude = (double)(record.Fields["lon"]); //if (record.Fields.ContainsKey("lat")) item.Latitude = (double)(record.Fields["lat"]); //if (record.Fields.ContainsKey("eqid")) item.Id = (string)(record.Fields["eqid"]); //if (record.Fields.ContainsKey("depth")) item.Depth = (double)(record.Fields["depth"]); //if (record.Fields.ContainsKey("magnitude")) item.Magnitude = (double)(record.Fields["magnitude"]); //if (record.Fields.ContainsKey("region")) item.Region = (string)(record.Fields["region"]); //if (record.Fields.ContainsKey("datetime")) item.Description = (string)(record.Fields["datetime"]); // TODO-MT parse date time //location.Updated = (System.DateTime)(record.Fields["datetime"]); // Sun Jun 13 00:00:00 -0400 2010 item.Longitude = record.Fields.GetValue <double>("lon"); item.Latitude = record.Fields.GetValue <double>("lat"); item.Code = record.Fields.GetValue <string>("eqid"); item.Depth = record.Fields.GetValue <double>("depth"); item.Magnitude = record.Fields.GetValue <double>("magnitude"); item.Region = record.Fields.GetValue <string>("region"); item.Description = record.Fields.GetValue <string>("datetime"); item.Label = "Earthquake: " + item.Magnitude + Environment.NewLine + item.Region // + Environment.NewLine + "Longitude: " + String.Format("{0:0.0}", item.Longitude) // + Environment.NewLine + "Latitude: " + String.Format("{0:0.0}", item.Latitude) + Environment.NewLine + "Location: " + String.Format("{0:0.0}", item.Longitude) + ", " + String.Format("{0:0.0}", item.Latitude); // update countries stats earthQuakes.Magnitude.Update(item.Magnitude); earthQuakes.Depth.Update(item.Depth); // add an item to data collection earthQuakes.Add(item); } } return(earthQuakes); }