コード例 #1
0
ファイル: WSUtilities.cs プロジェクト: quanted/hms
        /// <summary>
        /// Checks the data endpoints for the Soil Moisture component.
        /// </summary>
        /// <returns></returns>
        public static async Task <Dictionary <string, Dictionary <string, string> > > CheckSoilMEndpoints()
        {
            Dictionary <string, Dictionary <string, string> > endpoints = new Dictionary <string, Dictionary <string, string> >();
            List <SoilMoisture.SoilMoisture> soils = new List <SoilMoisture.SoilMoisture>();
            List <string> sources = new List <string>()
            {
                "nldas", "gldas"
            };
            ITimeSeriesInput testInput = new TimeSeriesInput()
            {
                Source       = "nldas",
                DateTimeSpan = new DateTimeSpan()
                {
                    StartDate = new DateTime(2005, 01, 01),
                    EndDate   = new DateTime(2005, 01, 05)
                },
                Geometry = new TimeSeriesGeometry()
                {
                    Point = new PointCoordinate()
                    {
                        Latitude  = 33.925673,
                        Longitude = -83.355723
                    },
                    GeometryMetadata = new Dictionary <string, string>()
                }
            };
            ITimeSeriesInputFactory iFactory = new TimeSeriesInputFactory();

            foreach (string source in sources)
            {
                string[] validLayers = (source.Contains("nldas")) ? new string[] { "0-10", "10-40", "40-100", "100-200", "0-100", "0-200" } : new string[] { "0-10", "10-40", "40-100", "0-100" };
                foreach (string layer in validLayers)
                {
                    SoilMoisture.SoilMoisture soil = new SoilMoisture.SoilMoisture();
                    testInput.Source = source;
                    string l = layer.Replace('-', '_') + "_soilmoisture";
                    soil.Input = iFactory.SetTimeSeriesInput(testInput, new List <string>()
                    {
                        l
                    }, out string errorMsg);
                    soil.Input.Source = source + "_" + l;
                    soils.Add(soil);
                }
            }

            Parallel.ForEach(soils, (SoilMoisture.SoilMoisture soil) =>
            {
                endpoints.Add(soil.Input.Source, soil.CheckEndpointStatus());
            });
            return(endpoints);
        }