コード例 #1
0
        private Data.Polygon GetPolygon(double bottom, double left, double right, double top)
        {
            Data.Polygon polygon = new Data.Polygon();
            polygon.LinearRings = new List <ILinearRing>();
            Data.LinearRing linearRing = new LinearRing();
            BoundingBox     swedenExtentBoundingBox = SwedenExtentManager.GetSwedenExtentBoundingBox(MySettings.Presentation.Map.DisplayCoordinateSystem);

            double limitBottom = bottom;
            double limitLeft   = left;
            double limitRight  = right;
            double limitTop    = top;

            limitBottom = Math.Max(bottom, swedenExtentBoundingBox.Min.Y);
            limitTop    = Math.Min(top, swedenExtentBoundingBox.Max.Y);
            limitLeft   = Math.Max(left, swedenExtentBoundingBox.Min.X);
            limitRight  = Math.Min(right, swedenExtentBoundingBox.Max.X);

            linearRing.Points = new List <IPoint>();
            linearRing.Points.Add(new Data.Point(limitLeft, limitBottom));
            linearRing.Points.Add(new Data.Point(limitLeft, limitTop));
            linearRing.Points.Add(new Data.Point(limitRight, limitTop));
            linearRing.Points.Add(new Data.Point(limitRight, limitBottom));
            linearRing.Points.Add(new Data.Point(limitLeft, limitBottom));
            polygon.LinearRings.Add(linearRing);
            return(polygon);
        }
コード例 #2
0
        private Data.Polygon GetPolygon(double bottom, double left, double right, double top)
        {
            Data.Polygon polygon = new Data.Polygon();
            polygon.LinearRings = new List <ILinearRing>();
            Data.LinearRing linearRing = new LinearRing();

            linearRing.Points = new List <IPoint>();
            linearRing.Points.Add(new Data.Point(left, bottom));
            linearRing.Points.Add(new Data.Point(left, top));
            linearRing.Points.Add(new Data.Point(right, top));
            linearRing.Points.Add(new Data.Point(right, bottom));
            linearRing.Points.Add(new Data.Point(left, bottom));

            polygon.LinearRings.Add(linearRing);

            return(polygon);
        }
コード例 #3
0
        public string GetSpeciesObservationAOOEOOAsGeoJson(int?alphaValue = null, bool useCenterPoint = false)
        {
            var gridResult = GetSpeciesObservationGridResultFromCacheIfAvailableOrElseCalculate();

            if (gridResult == null)
            {
                return(null);
            }

            //Convert SpeciesObservationGridResult to List<IGridCellSpeciesObservationCount>
            //Todo Cache List<IGridCellSpeciesObservationCount> from service and not SpeciesObservationGridResult var gridCellsc = CalculateSpeciesObservationGrid();
            var gridCells = new List <IGridCellSpeciesObservationCount>();

            foreach (var sourceCell in gridResult.Cells)
            {
                var targetCell = new GridCellSpeciesObservationCount();

                if (sourceCell.BoundingBox != null)
                {
                    var linearRing = new LinearRing()
                    {
                        Points = new DataId32List <IPoint>()
                    };

                    foreach (var point in sourceCell.BoundingBox)
                    {
                        linearRing.Points.Add(new Data.Point(point[0], point[1]));
                    }
                    var firstPoint = sourceCell.BoundingBox[0]; //Add first point to close ring
                    linearRing.Points.Add(new Data.Point(firstPoint[0], firstPoint[1]));

                    var boundingBoxPolygon = new Data.Polygon()
                    {
                        LinearRings = new DataId32List <ILinearRing>()
                    };
                    boundingBoxPolygon.LinearRings.Add(linearRing);
                    targetCell.GridCellBoundingBox = boundingBoxPolygon;
                }

                if (sourceCell.OriginalBoundingBox != null && sourceCell.OriginalBoundingBox.Length == 4)
                {
                    targetCell.OrginalGridCellBoundingBox = new Data.BoundingBox
                    {
                        Min = new Data.Point(sourceCell.OriginalBoundingBox[0, 0], sourceCell.OriginalBoundingBox[0, 1]),
                        Max = new Data.Point(sourceCell.OriginalBoundingBox[1, 0], sourceCell.OriginalBoundingBox[1, 1])
                    };
                }

                if (sourceCell.CentreCoordinate != null)
                {
                    targetCell.GridCellCentreCoordinate = new Data.Point(sourceCell.CentreCoordinateX, sourceCell.CentreCoordinateY);
                }
                targetCell.OrginalGridCellCentreCoordinate = new Data.Point(sourceCell.OriginalCentreCoordinateX, sourceCell.OriginalCentreCoordinateY);
                targetCell.ObservationCount     = sourceCell.ObservationCount;
                targetCell.GridCellSize         = sourceCell.GridCellSize;
                targetCell.CoordinateSystem     = MySettings.Presentation.Map.DisplayCoordinateSystem;
                targetCell.GridCoordinateSystem = sourceCell.Srid.ToGridCoordinateSystem();

                gridCells.Add(targetCell);
            }

            return(CoreData.AnalysisManager.GetSpeciesObservationAOOEOOAsGeoJson(UserContext, gridCells, alphaValue ?? 0, useCenterPoint));
        }