/// <summary>
 /// Check if grid specifications is correct.
 /// </summary>
 /// <param name="gridSpecification"> Information on grid specifications.</param>
 /// <param name="speciesObservationBoundingBox">Bounding box for species observation.</param>
 public static void CheckGridSpecifications(this WebGridSpecification gridSpecification, WebBoundingBox speciesObservationBoundingBox)
 {
     if (gridSpecification.IsNotNull() && gridSpecification.BoundingBox.IsNotNull())
     {
         if (speciesObservationBoundingBox.IsNotNull())
         {
             throw new ArgumentException("WebGridSpecifications: Properties WebGridSpecifications.BoundingBox and WebSpeciesObservatioSearchCriteria.BoundingBox have value set, only one BoundigBox can be set.");
         }
     }
 }
 /// <summary>
 /// Test if point is located inside bounding box.
 /// Currently only two dimensions are handled.
 /// </summary>
 /// <param name="boundingBox">Bounding box.</param>
 /// <param name='point'>Point.</param>
 /// <returns>True if point is located inside bounding box.</returns>
 public static Boolean IsPointInside(this WebBoundingBox boundingBox,
                                     WebPoint point)
 {
     return(boundingBox.IsNotNull() &&
            point.IsNotNull() &&
            (boundingBox.Max.X >= point.X) &&
            (boundingBox.Min.X <= point.X) &&
            (boundingBox.Max.Y >= point.Y) &&
            (boundingBox.Min.Y <= point.Y));
 }
        /// <summary>
        /// Check that data is valid.
        /// </summary>
        /// <param name="boundingBox">Bounding box.</param>
        public static void CheckData(this WebBoundingBox boundingBox)
        {
            if (boundingBox.IsNotNull())
            {
                // Check points.
                boundingBox.Max.CheckNotNull("Max");
                boundingBox.Max.CheckData();
                boundingBox.Min.CheckNotNull("Min");
                boundingBox.Min.CheckData();

                // Check that points are of the same dimension.
                if (boundingBox.Max.IsMSpecified !=
                    boundingBox.Min.IsMSpecified)
                {
                    throw new ArgumentException("WebBoundingBox: Min and max has different M dimensions");
                }
                if (boundingBox.Max.IsZSpecified !=
                    boundingBox.Min.IsZSpecified)
                {
                    throw new ArgumentException("WebBoundingBox: Min and max has different Z dimensions");
                }

                // Check that all min values are lower than all max values.
                if (boundingBox.Max.X < boundingBox.Min.X)
                {
                    throw new ArgumentException("WebBoundingBox: Max.X is smaller than Min.X");
                }
                if (boundingBox.Max.Y < boundingBox.Min.Y)
                {
                    throw new ArgumentException("WebBoundingBox: Max.Y is smaller than Min.Y");
                }
                if (boundingBox.Max.IsZSpecified &&
                    (boundingBox.Max.Z < boundingBox.Min.Z))
                {
                    throw new ArgumentException("WebBoundingBox: Max.Z is smaller than Min.Z");
                }
                if (boundingBox.Max.IsMSpecified &&
                    (boundingBox.Max.M < boundingBox.Min.M))
                {
                    throw new ArgumentException("WebBoundingBox: Max.M is smaller than Min.M");
                }
            }
        }