Beispiel #1
0
        /// <summary>
        /// Updates the UI after new earthquake data is retrieved. *Must* be called on the UI thread.
        /// </summary>
        /// <param name="data"></param>
        void DisplayEarthquakes(GeoJSON.RootObject data)
        {
            earthquakes.Clear();

            foreach (var feature in data.features)
            {
                GeoJSON.Properties props     = feature.properties;
                List <double>      coords    = feature.geometry.coordinates;
                double             longitude = coords[1];
                double             latitude  = coords[0];
                double             depth     = coords[2];

                List <WorldCities.CityDistance> nearestCities = cities.GetNearestCities(new GeoCoordinate(longitude, latitude));

                var rec = new EarthquakeRecord(
                    GeoJSON.Utils.TimeStampToDateTime(props.time),
                    props.mag,
                    longitude,
                    latitude,
                    depth,
                    string.Join(", ", nearestCities.ConvertAll(new Converter <WorldCities.CityDistance, string>((c) => c.ToString())))
                    );

                earthquakes.Add(rec);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Called when the <see cref="GeoJSON.PollingClient"/> gets new data. Need not be called on the UI thread.
 /// </summary>
 /// <param name="data">Retrieved data.</param>
 void OnDataReceived(GeoJSON.RootObject data)
 {
     Dispatcher.BeginInvoke(new Action(() => DisplayEarthquakes(data)));
 }