Beispiel #1
0
        private static void GetRainMeasurements()
        {
            var timeBetweenMeasurements = new TimeSpan(0, 0, 1, 0);
            var publicDataService       = new PublicDataService(_authenticationToken);

            double latitute  = Convert.ToDouble(ConfigurationManager.AppSettings["Latitude"]);
            double longitude = Convert.ToDouble(ConfigurationManager.AppSettings["Longitude"]);

            var             center  = new LatLongPoint(latitute, longitude);
            LocationBoundry boundry = LocationBoundry.ComputeBoundry(center);

            Console.WriteLine("Count\tWith gauge\tWith Rain\tAverage\tMin\tMax\t");
            do
            {
                // Get the public data
                PublicData publicData = publicDataService.Get(boundry);

                // The total number of stations returned in the geographic area.
                int totalNumberOfStations = publicData.Stations.Count();

                // The stations that have a rain gauge.
                var rainStations = GetStationsWithRainSensors(publicData);
                int numberOfStationsWithRainGauge = rainStations.Count();

                // Stations where the rain gauge is reporting a level above the threshold.
                var stationsWithRain = rainStations.Where(x => x.Value > RainingThreshold).ToList();

                ShowComputedStatistics(totalNumberOfStations, numberOfStationsWithRainGauge, stationsWithRain);

                WaitForNextMeasurementTime(timeBetweenMeasurements);
            } while (!CancellationToken.IsCancellationRequested);
        }
Beispiel #2
0
        private static void GetRainMeasurements()
        {
            var timeBetweenMeasurements = new TimeSpan(0, 0, 1, 0);
            var publicDataService       = new PublicDataService(_authenticationToken, new HttpWrapper());

            var boundry = GetLocationBoundry();

            Console.WriteLine("Count\tWith gauge\tWith Rain\tAverage\tMin\tMax\t");
            do
            {
                if (_authenticationToken.IsCloseToExpiry())
                {
                    RefreshToken();
                }

                // Get the public data
                PublicData publicData = publicDataService.Get(boundry).Result;

                // The total number of stations returned in the geographic area.
                int totalNumberOfStations = publicData.Stations.Count();
                Trace.WriteLine("Total number of stations: " + totalNumberOfStations);

                // The stations that have a rain gauge.
                var rainStations = GetStationsWithRainSensors(publicData);
                int numberOfStationsWithRainGauge = rainStations.Count();
                Trace.WriteLine("Number of stations with rain gauge: " + numberOfStationsWithRainGauge);

                // Stations where the rain gauge is reporting a level above the threshold.
                var stationsWithRain = rainStations.Where(x => x.Value > RainingThreshold).ToList();

                ShowComputedStatistics(totalNumberOfStations, numberOfStationsWithRainGauge, stationsWithRain);

                WaitForNextMeasurementTime(timeBetweenMeasurements);
            } while (!CancellationToken.IsCancellationRequested);
        }
Beispiel #3
0
        [TestCase(49.281974, -123.117857)] // Vancouver, BC, Canada
        public void DifferentLocations(double latitute, double longitude)
        {
            // Arrange
            var publicDataService = new PublicDataService(_authenticationToken, new HttpWrapper());

            var             center  = new LatLongPoint(latitute, longitude);
            LocationBoundry boundry = LocationBoundry.ComputeBoundry(center, 10);

            // Act
            PublicData publicData = publicDataService.Get(boundry).Result;

            // Assert
            Assert.IsNotNull(publicData);

            ShowStationInfo(publicData.Stations, center);
            ShowRainInfo(publicData);
        }
Beispiel #4
0
        public void GetPublicData()
        {
            // Arrange
            var publicDataService = new PublicDataService(_authenticationToken, new HttpWrapper());

            // home
            double latitute  = Convert.ToDouble(ConfigurationManager.AppSettings["Latitude"]);
            double longitude = Convert.ToDouble(ConfigurationManager.AppSettings["Longitude"]);

            var             center  = new LatLongPoint(latitute, longitude);
            LocationBoundry boundry = LocationBoundry.ComputeBoundry(center, 10);

            // Act
            PublicData publicData = publicDataService.Get(boundry).Result;

            // Assert
            Assert.IsNotNull(publicData);

            ShowStationInfo(publicData.Stations, center);

            ShowRainInfo(publicData);
        }
Beispiel #5
0
        public void GetPublicData()
        {
            // Arrange
            var publicDataService = new PublicDataService(_authenticationToken);

            double latitute  = Convert.ToDouble(ConfigurationManager.AppSettings["Latitude"]);
            double longitude = Convert.ToDouble(ConfigurationManager.AppSettings["Longitude"]);

            var             center  = new LatLongPoint(latitute, longitude);
            LocationBoundry boundry = LocationBoundry.ComputeBoundry(center);

            // Act
            PublicData publicData = publicDataService.Get(boundry);

            // Assert
            Assert.IsNotNull(publicData);


            IList <SensorMeasurement> rainStations = new List <SensorMeasurement>();

            foreach (var station in publicData.Stations)
            {
                var rainMeasurement = station.Measurements.FirstOrDefault(y => y is RainMeasurement);
                if (rainMeasurement != null)
                {
                    rainStations.Add(rainMeasurement);
                }
            }

            Trace.WriteLine("All Stations: ");
            ShowComputedStatistics(rainStations);

            Trace.WriteLine("Stations with Rain: ");
            var stationsWithRain = rainStations.Where(x => x.Value > 0.1M).ToList();

            ShowComputedStatistics(stationsWithRain);
        }