示例#1
0
        /// <summary>
        /// Validates input geometry.
        /// Valid inputs: Point.Latitude/Point.Longitude, HucID, ComID, StationID
        /// One valid input must be provided.
        /// </summary>
        /// <param name="errors"></param>
        /// <param name="geometry"></param>
        /// <returns></returns>
        public static bool ValidateGeometry(out List <string> errors, ITimeSeriesGeometry geometry)
        {
            errors = new List <string>();
            List <string> errorTemp = new List <string>();
            bool          validGeom = true;

            if (geometry == null)
            {
                errors.Add("ERROR: No input geometry was found.");
                return(false);
            }
            if (string.IsNullOrWhiteSpace(geometry.Description))
            {
                if (geometry.Point != null)
                {
                    validGeom = ValidatePoint(out errorTemp, geometry.Point);
                    errors    = errors.Concat(errorTemp).ToList();
                }
                if (!validGeom && !string.IsNullOrWhiteSpace(geometry.HucID.ToString()))
                {
                    validGeom = ValidateHucID(out errorTemp, geometry.HucID);
                    errors    = errors.Concat(errorTemp).ToList();
                }
                if (!validGeom && !string.IsNullOrWhiteSpace(geometry.ComID.ToString()))
                {
                    validGeom = ValidateComID(out errorTemp, geometry.ComID);
                    errors    = errors.Concat(errorTemp).ToList();
                }
                if (!validGeom && !string.IsNullOrWhiteSpace(geometry.StationID))
                {
                    validGeom = ValidateStationID(out errorTemp, geometry.StationID);
                    errors    = errors.Concat(errorTemp).ToList();
                }
            }
            else
            {
                switch (geometry.Description.ToLower())
                {
                case "point":
                    validGeom = ValidatePoint(out errors, geometry.Point);
                    break;

                case "hucid":
                    validGeom = ValidateHucID(out errors, geometry.HucID);
                    break;

                case "comid":
                    validGeom = ValidateComID(out errors, geometry.ComID);
                    break;

                case "stationid":
                    validGeom = ValidateStationID(out errors, geometry.StationID);
                    break;

                default:
                    geometry.Description = "";
                    validGeom            = ValidateGeometry(out errors, geometry);
                    break;
                }
            }
            return(validGeom);
        }