예제 #1
0
        /// <summary>
        /// Creates a new grid cell result.
        /// </summary>
        /// <param name="gridCell">The grid cell object returned from web service.</param>
        public static TaxonGridCellResult Create(IGridCellSpeciesCount gridCell)
        {
            var model = new TaxonGridCellResult();

            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;
            model.ObservationCount          = gridCell.ObservationCount;
            model.SpeciesCount = gridCell.SpeciesCount;
            model.GridCellSize = gridCell.GridCellSize;
            model.Srid         = gridCell.GridCoordinateSystem.Srid();
            return(model);
        }
        /// <summary>
        /// Creates a Grid statistics result object.
        /// </summary>
        /// <param name="cells">Grid statistics cell list returned from web service.</param>
        /// <returns></returns>
        public static TaxonGridResult Create(IList <IGridCellSpeciesCount> cells)
        {
            var model = new TaxonGridResult();

            model.Cells = new List <TaxonGridCellResult>();
            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 (GridCellSpeciesCount gridCell in cells)
            {
                model.Cells.Add(TaxonGridCellResult.Create(gridCell));
            }
            return(model);
        }