public static SpeciesObservationGridResult CreateGridCellTestDataUsingGoogleMercator(int nrRows, int nrColumns, int gridSize)
        {
            var result = new SpeciesObservationGridResult();

            //double[] upperLeftStartCoordinate = {15.569241, 58.3898709}; // Linköping
            //double[] leftUpperStartCoordinate = { 15.416564941405483, 60.479793034510955 }; // Borlänge

            double[] centerStartCoordinate         = { 15.416564941405483, 60.479793034510955 }; // Borlänge
            double[] mercatorCenterStartCoordinate = Wgs84Util.WGS84ToGoogleMercator(centerStartCoordinate);

            //double[] currentSouthWestCoordinate;
            //double[] currentNorthEastCoordinate;

            result.GridCellCoordinateSystem   = "GoogleMercator";
            result.GridCellCoordinateSystemId = 3;
            result.GridCellSize = gridSize;
            result.Cells        = new List <SpeciesObservationGridCellResult>();

            for (int i = 0; i < nrRows; i++)
            {
                for (int j = 0; j < nrColumns; j++)
                {
                    double[] mercatorCenterCoordinate = new double[] { mercatorCenterStartCoordinate[0] + (j * gridSize), mercatorCenterStartCoordinate[1] - (i * gridSize) };
                    double   halfGridSize             = gridSize / 2.0;

                    //double[] currentWestNorthCoordinate = Wgs84Util.TranslateCoordinate(leftUpperStartCoordinate, j * gridSize, -i * gridSize);
                    //double[] currentEastSouthCoordinate = Wgs84Util.TranslateCoordinate(currentWestNorthCoordinate, gridSize, -gridSize);
                    //double[] currentCentreCoordinate = Wgs84Util.TranslateCoordinate(currentWestNorthCoordinate, gridSize / 2.0, -gridSize / 2.0);

                    //double[] mercatorCurrentWestNorthCoordinate = Wgs84Util.WGS84ToGoogleMercator(currentWestNorthCoordinate);
                    //double[] mercatorCurrentEastSouthCoordinate = Wgs84Util.WGS84ToGoogleMercator(currentEastSouthCoordinate);
                    //double[] mercatorCurrentCentreCoordinate = Wgs84Util.WGS84ToGoogleMercator(currentCentreCoordinate);

                    var gridCell = new SpeciesObservationGridCellResult();
                    gridCell.CentreCoordinateX = mercatorCenterCoordinate[0];
                    gridCell.CentreCoordinateY = mercatorCenterCoordinate[1];
                    gridCell.CentreCoordinate  = mercatorCenterCoordinate;

                    gridCell.BoundingBox[0] = new[] { mercatorCenterCoordinate[0] - halfGridSize, mercatorCenterCoordinate[1] - halfGridSize };
                    gridCell.BoundingBox[2] = new[] { mercatorCenterCoordinate[0] + halfGridSize, mercatorCenterCoordinate[1] + halfGridSize };

                    gridCell.ObservationCount = _random.Next(0, 200);
                    result.Cells.Add(gridCell);
                }
            }

            return(result);
        }
        /// <summary>
        /// Creates a Grid statistics result object.
        /// </summary>
        /// <param name="cells">Grid statistics cell list returned from web service.</param>
        /// <returns></returns>
        public static SpeciesObservationGridResult Create(IList <IGridCellSpeciesObservationCount> cells)
        {
            var model = new SpeciesObservationGridResult();

            model.Cells = new List <SpeciesObservationGridCellResult>();
            model.GridCellCoordinateSystem = "";

            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 (GridCellSpeciesObservationCount gridCell in cells)
            {
                model.Cells.Add(SpeciesObservationGridCellResult.Create(gridCell));
            }
            return(model);
        }