/// <summary>
        /// Creates a new grid cell result.
        /// </summary>
        /// <param name="gridCell">The grid cell object returned from web service.</param>
        public static CombinedGridStatisticsCellResult Create(IGridCellCombinedStatistics gridCell)
        {
            CombinedGridStatisticsCellResult model = new CombinedGridStatisticsCellResult();

            model.BoundingBox = new double[4][];
            for (int i = 0; i < 4; i++)
            {
                IPoint point = gridCell.GridCellBoundingBox.LinearRings[0].Points[i];
                model.BoundingBox[i] = new[] { point.X, point.Y };
            }

            model.CentreCoordinateX         = gridCell.GridCellCentreCoordinate.X;
            model.CentreCoordinateY         = gridCell.GridCellCentreCoordinate.Y;
            model.OriginalCentreCoordinateX = gridCell.OrginalGridCellCentreCoordinate.X;
            model.OriginalCentreCoordinateY = gridCell.OrginalGridCellCentreCoordinate.Y;

            if (gridCell.SpeciesCount != null)
            {
                model.ObservationCount = gridCell.SpeciesCount.ObservationCount;
                model.SpeciesCount     = gridCell.SpeciesCount.SpeciesCount;
            }

            if (gridCell.FeatureStatistics != null)
            {
                model.FeatureCount  = gridCell.FeatureStatistics.FeatureCount;
                model.FeatureArea   = gridCell.FeatureStatistics.FeatureArea;
                model.FeatureLength = gridCell.FeatureStatistics.FeatureLength;
            }

            model.GridCellSize = gridCell.GridCellSize;
            model.Srid         = gridCell.GridCoordinateSystem.Srid();

            return(model);
        }
        /// <summary>
        /// Creates a Grid statistics result object.
        /// </summary>
        /// <param name="calculationCoordinateSystemId">The calculation coordinate system id.</param>
        /// <param name="displayCoordinateSystemId">The display coordinate system id.</param>
        /// <param name="gridCellSize">Size of the grid cell.</param>
        /// <param name="cells">Grid statistics cell list returned from web service.</param>
        /// <returns></returns>
        public static CombinedGridStatisticsResult Create(
            CoordinateSystemId calculationCoordinateSystemId,
            CoordinateSystemId displayCoordinateSystemId,
            int gridCellSize,
            IList <IGridCellCombinedStatistics> cells)
        {
            var model = new CombinedGridStatisticsResult();

            model.Cells = new List <CombinedGridStatisticsCellResult>();
            model.CalculationCoordinateSystemId   = (int)displayCoordinateSystemId;
            model.CalculationCoordinateSystemName = CoordinateSystemHelper.GetCoordinateSystemName(calculationCoordinateSystemId);
            model.DisplayCoordinateSystemId       = (int)calculationCoordinateSystemId;
            model.DisplayCoordinateSystemName     = CoordinateSystemHelper.GetCoordinateSystemName(displayCoordinateSystemId);
            model.GridCellSize = gridCellSize;

            if (cells == null || cells.Count == 0)
            {
                return(model);
            }
            //model.GridCellSize = cells[0].GridCellSize;
            //model.GridCellCoordinateSystemId = (int)cells[0].GridCoordinateSystem;
            //model.GridCellCoordinateSystem = cells[0].GridCoordinateSystem.ToString();
            foreach (IGridCellCombinedStatistics gridCell in cells)
            {
                model.Cells.Add(CombinedGridStatisticsCellResult.Create(gridCell));
            }
            return(model);
        }