Example #1
0
        /// <summary>
        /// Adds the headers.
        /// </summary>
        /// <param name="worksheet">The worksheet.</param>
        private void AddHeaders(ExcelWorksheet worksheet, CombinedGridStatisticsResult data)
        {
            //Add row with column headers
            worksheet.Cells[1, 1].Value  = "Id";
            worksheet.Cells[1, 2].Value  = Resource.GridStatisticsTaxaCount;
            worksheet.Cells[1, 3].Value  = Resource.GridStatisticsObservationCount;
            worksheet.Cells[1, 4].Value  = string.Format("{1} ({0})", Resource.GridStatisticsEnvironmentalData, Resource.GridStatisticsCalculationModeCount);
            worksheet.Cells[1, 5].Value  = string.Format("{1} ({0})", Resource.GridStatisticsEnvironmentalData, Resource.GridStatisticsCalculationModeArea);
            worksheet.Cells[1, 6].Value  = string.Format("{1} ({0})", Resource.GridStatisticsEnvironmentalData, Resource.GridStatisticsCalculationModeLength);
            worksheet.Cells[1, 7].Value  = string.Format("{0} X - {1} ({2})", Resource.GridStatisticsCentreCoordinate, Resource.GridStatisticsCalculation, data.CalculationCoordinateSystemName);
            worksheet.Cells[1, 8].Value  = string.Format("{0} Y - {1} ({2})", Resource.GridStatisticsCentreCoordinate, Resource.GridStatisticsCalculation, data.CalculationCoordinateSystemName);
            worksheet.Cells[1, 9].Value  = string.Format("{0} X - {1} ({2})", Resource.GridStatisticsCentreCoordinate, Resource.GridStatisticsDisplay, data.DisplayCoordinateSystemName);
            worksheet.Cells[1, 10].Value = string.Format("{0} Y - {1} ({2})", Resource.GridStatisticsCentreCoordinate, Resource.GridStatisticsDisplay, data.DisplayCoordinateSystemName);
            worksheet.Cells[1, 11].Value = Resource.GridStatisticsCellSizeMeters;

            //Set column widths
            worksheet.Column(1).Width  = 38;
            worksheet.Column(2).Width  = 19;
            worksheet.Column(3).Width  = 19;
            worksheet.Column(4).Width  = 23;
            worksheet.Column(5).Width  = 23;
            worksheet.Column(6).Width  = 23;
            worksheet.Column(7).Width  = 23;
            worksheet.Column(8).Width  = 36;
            worksheet.Column(9).Width  = 36;
            worksheet.Column(10).Width = 36;
            worksheet.Column(11).Width = 36;
        }
Example #2
0
        /// <summary>
        /// Calculates the combined grid result.
        /// </summary>
        /// <param name="calculationCoordinateSystemId">The calculation coordinate system id.</param>
        /// <param name="gridCellSize">Size of the grid cell.</param>
        /// <param name="wfsLayerId">The WFS layer id.</param>
        /// <returns>Combined grid cell statistics.</returns>
        public CombinedGridStatisticsResult CalculateCombinedGridResult(int calculationCoordinateSystemId, int gridCellSize, int wfsLayerId)
        {
            GridSpecification gridSpecification       = new GridSpecification();
            CoordinateSystem  displayCoordinateSystem = MySettings.Presentation.Map.DisplayCoordinateSystem;

            gridSpecification.GridCoordinateSystem    = (GridCoordinateSystem)calculationCoordinateSystemId;
            gridSpecification.GridCellSize            = gridCellSize;
            gridSpecification.IsGridCellSizeSpecified = true;
            gridSpecification.GridCellGeometryType    = GridCellGeometryType.Polygon;
            if (MySettings.Filter.Spatial.IsActive)
            {
                // Create bounding box from spatial filter
                ObservableCollection <DataPolygon> polygons = MySettings.Filter.Spatial.Polygons;
                if (polygons.Count > 0)
                {
                    BoundingBox      boundingBox                 = polygons.GetBoundingBox();
                    CoordinateSystem toCoordinateSystem          = CoordinateSystemHelper.GetCoordinateSystemFromGridCoordinateSystem(gridSpecification.GridCoordinateSystem);
                    IPolygon         convertedBoundingBoxPolygon = GisTools.CoordinateConversionManager.GetConvertedBoundingBox(boundingBox, MySettings.Filter.Spatial.PolygonsCoordinateSystem, toCoordinateSystem);
                    BoundingBox      convertedBoundingBox        = convertedBoundingBoxPolygon.GetBoundingBox();
                    gridSpecification.BoundingBox = convertedBoundingBox;
                }
            }

            WfsLayerSetting wfsLayer              = SessionHandler.MySettings.DataProvider.MapLayers.WfsLayers.FirstOrDefault(l => l.Id == wfsLayerId);
            string          featuresUrl           = "";
            string          featureCollectionJson = null;

            if (wfsLayer.IsFile)
            {
                featureCollectionJson = JObject.FromObject(MySettingsManager.GetMapDataFeatureCollection(UserContext, wfsLayer.GeometryName, gridSpecification.GridCoordinateSystem.GetCoordinateSystemId())).ToString();
            }
            else
            {
                if (string.IsNullOrEmpty(wfsLayer.Filter))
                {
                    featuresUrl = string.Format("{0}?service=wfs&version=1.1.0&request=GetFeature&typeName={1}",
                                                wfsLayer.ServerUrl, wfsLayer.TypeName);
                }
                else
                {
                    featuresUrl =
                        string.Format("{0}?service=wfs&version=1.1.0&request=GetFeature&typeName={1}&filter={2}",
                                      wfsLayer.ServerUrl, wfsLayer.TypeName, wfsLayer.Filter);
                }
            }
            var speciesObservationSearchCriteriaManager        = new SpeciesObservationSearchCriteriaManager(UserContext);
            SpeciesObservationSearchCriteria    searchCriteria = speciesObservationSearchCriteriaManager.CreateSearchCriteria(MySettings);
            IList <IGridCellCombinedStatistics> gridCells      = CoreData.AnalysisManager.GetGridCellFeatureStatisticsCombinedWithSpeciesObservationCounts(UserContext, gridSpecification, searchCriteria, null, featuresUrl, featureCollectionJson, displayCoordinateSystem);

            if (MySettings.Calculation.GridStatistics.GenerateAllGridCells)
            {
                gridCells = AddEmptyGridCells(gridCells, gridSpecification, displayCoordinateSystem);
                gridCells = RemoveGridCellsOutsideBounds(gridCells, gridSpecification);
            }

            gridCells = gridCells.OrderBy(x => x.Identifier).ToList();
            return(CombinedGridStatisticsResult.Create(
                       (CoordinateSystemId)calculationCoordinateSystemId, displayCoordinateSystem.Id, gridCellSize, gridCells));
        }
Example #3
0
        private void AddSpeciesObservationsData(ExcelWorksheet worksheet, CombinedGridStatisticsResult data)
        {
            Int32 columnIndex;
            Int32 rowIndex;

            columnIndex = 1;
            rowIndex    = 2;

            // Data values
            foreach (var row in data.Cells)
            {
                worksheet.Cells[rowIndex, columnIndex].Value = row.Identifier;
                columnIndex++;
                worksheet.Cells[rowIndex, columnIndex].Value = row.SpeciesCount;
                columnIndex++;
                worksheet.Cells[rowIndex, columnIndex].Value = row.ObservationCount;
                columnIndex++;
                worksheet.Cells[rowIndex, columnIndex].Value = row.FeatureCount;
                columnIndex++;
                worksheet.Cells[rowIndex, columnIndex].Value = row.FeatureArea;
                columnIndex++;
                worksheet.Cells[rowIndex, columnIndex].Value = row.FeatureLength;
                columnIndex++;
                worksheet.Cells[rowIndex, columnIndex].Value = row.OriginalCentreCoordinateX; //"Centrum X (SWEREF 99)"
                columnIndex++;
                worksheet.Cells[rowIndex, columnIndex].Value = row.OriginalCentreCoordinateY; //"Centrum Y (SWEREF 99)"
                columnIndex++;
                worksheet.Cells[rowIndex, columnIndex].Value = row.CentreCoordinateX;         //"Centrum X (Google Mercator)"
                columnIndex++;
                worksheet.Cells[rowIndex, columnIndex].Value = row.CentreCoordinateY;         //"Centrum Y (Google Mercator)"
                columnIndex++;
                worksheet.Cells[rowIndex, columnIndex].Value = row.GridCellSize;              //"Centrum X (Google Mercator)"

                columnIndex = 1;
                rowIndex++;
            }
        }