Exemple #1
0
 /// <summary>
 /// Check soil moisture data endpoints.
 /// </summary>
 /// <returns></returns>
 public Dictionary <string, string> CheckEndpointStatus()
 {
     if (this.Input.Source.Contains("nldas"))
     {
         return(NLDAS.CheckStatus(this.Input));
     }
     else if (this.Input.Source.Contains("gldas"))
     {
         return(GLDAS.CheckStatus(this.Input));
     }
     else
     {
         return(new Dictionary <string, string>()
         {
             { "status", "invalid source" }
         });
     }
 }
Exemple #2
0
        // -------------- SoilMoisture Functions -------------- //

        /// <summary>
        /// Get SoilMoisture data function.
        /// </summary>
        /// <param name="errorMsg"></param>
        /// <returns></returns>
        public ITimeSeriesOutput GetData(out string errorMsg)
        {
            errorMsg = "";

            // If the timezone information is not provided, the tz details are retrieved and set to the geometry.timezone varaible.
            if (this.Input.Geometry.Timezone.Offset == 0)
            {
                Utilities.Time tz = new Utilities.Time();
                this.Input.Geometry.Timezone = tz.GetTimezone(out errorMsg, this.Input.Geometry.Point) as Timezone;
                if (errorMsg.Contains("ERROR"))
                {
                    return(null);
                }
            }

            if (!CheckLayers(out errorMsg))
            {
                return(null);
            }

            ITimeSeriesOutputFactory iFactory = new TimeSeriesOutputFactory();

            this.Output = iFactory.Initialize();

            switch (this.Input.Source)
            {
            case "nldas":
                // NLDAS SoilMoisture Data call
                NLDAS nldas = new NLDAS();
                this.Output = nldas.GetData(out errorMsg, this);
                if (errorMsg.Contains("ERROR"))
                {
                    return(null);
                }
                break;

            case "gldas":
                // GLDAS SoilMoisture Data call
                GLDAS gldas = new GLDAS();
                this.Output = gldas.GetData(out errorMsg, this);
                if (errorMsg.Contains("ERROR"))
                {
                    return(null);
                }
                break;

            default:
                errorMsg = "ERROR: 'Source' for SoilMoisture was not found among available sources or is invalid.";
                break;
            }
            ;

            // Adds Geometry metadata to the output metadata. NOT WORKING
            this.Output.Metadata.Concat(this.Input.Geometry.GeometryMetadata);

            // Adds Timezone info to metadata
            this.Output.Metadata.Add(this.Input.Source + "_timeZone", this.Input.Geometry.Timezone.Name);
            this.Output.Metadata.Add(this.Input.Source + "_tz_offset", this.Input.Geometry.Timezone.Offset.ToString());

            //TODO: Add output format control

            return(this.Output);
        }