/// <summary>
        /// Creates a view model for the "~/Result/ResultSpeciesObservationGridTable" view
        /// </summary>
        public ResultSpeciesObservationGridTableViewModel CreateResultSpeciesObservationGridTableViewModel()
        {
            var model = new ResultSpeciesObservationGridTableViewModel();

            if (GridStatisticsSetting.CoordinateSystemId != null)
            {
                GridCoordinateSystem coordinateSystem = (GridCoordinateSystem)GridStatisticsSetting.CoordinateSystemId;
                switch (coordinateSystem)
                {
                //case GridCoordinateSystem.RT90:
                case GridCoordinateSystem.Rt90_25_gon_v:
                    model.OriginalCoordinateSystemName = "RT 90";
                    break;

                case GridCoordinateSystem.SWEREF99_TM:
                    model.OriginalCoordinateSystemName = "SWEREF 99";
                    break;

                default:
                    model.OriginalCoordinateSystemName = "";
                    break;
                }
            }

            model.CoordinateSystemName = MySettings.Presentation.Map.PresentationCoordinateSystemId.GetCoordinateSystemName();
            model.CentreCoordinateName = Resources.Resource.GridStatisticsCentreCoordinate;
            return(model);
        }
        /// <summary>
        /// Gets the coordinate system from grid coordinate system.
        /// </summary>
        /// <param name="gridCoordinateSystem">The grid coordinate system.</param>
        /// <returns>The coordinate system that equals the <paramref name="gridCoordinateSystem"/>.</returns>
        public static CoordinateSystem GetCoordinateSystemFromGridCoordinateSystem(GridCoordinateSystem gridCoordinateSystem)
        {
            switch (gridCoordinateSystem)
            {
            case GridCoordinateSystem.GoogleMercator:
                return(new CoordinateSystem(CoordinateSystemId.GoogleMercator));

            case GridCoordinateSystem.Rt90_25_gon_v:
                return(new CoordinateSystem(CoordinateSystemId.Rt90_25_gon_v));

            case GridCoordinateSystem.SWEREF99_TM:
                return(new CoordinateSystem(CoordinateSystemId.SWEREF99_TM));

            default:
                return(new CoordinateSystem(CoordinateSystemId.None));
            }
        }
Beispiel #3
0
        /// <summary>
        /// Returns the corresponding srid for every defined coordinate system term.
        /// </summary>
        /// <param name="srid">the number of the coordinatesysteem as string.</param>
        /// <returns></returns>
        public static GridCoordinateSystem GetGridCoordinateSystemFromSrid(string srid)
        {
            GridCoordinateSystem gridCoordinateSystem;

            gridCoordinateSystem = new GridCoordinateSystem();
            if (srid.IsNull())
            {
                return(gridCoordinateSystem);
            }
            if (srid.Equals("3021"))
            {
                gridCoordinateSystem = GridCoordinateSystem.Rt90_25_gon_v;
            }
            else
            if (srid.Equals("3857"))
            {
                gridCoordinateSystem = GridCoordinateSystem.GoogleMercator;
            }
            else
            if (srid.Equals("900913"))
            {
                gridCoordinateSystem = GridCoordinateSystem.GoogleMercator;
            }
            else
            if (srid.Equals("3006"))
            {
                gridCoordinateSystem = GridCoordinateSystem.SWEREF99_TM;
            }
            else
            //if (srid.Equals("4378")) { gridCoordinateSystem = GridCoordinateSystem.SWEREF99; }
            //else
            //if (srid.Equals("4326")) { gridCoordinateSystem = GridCoordinateSystem.WGS84; }
            //else
            {
                throw new Exception("Coordinate system nor supported.");
            }
            return(gridCoordinateSystem);
        }
Beispiel #4
0
 /// <summary>
 /// Returns the corresponding srid for every defined coordinate system term.
 /// </summary>
 /// <param name="coordinateSystem">The enum term for the coordinate system.</param>
 /// <returns></returns>
 public static int GetSridFromGridCoordinateSystem(GridCoordinateSystem coordinateSystem)
 {
     if (coordinateSystem.ToString().Equals("RT90"))
     {
         return(3021);
     }              //4124;}
     else if (coordinateSystem.ToString().Equals("GoogleMercator"))
     //{return 900913;}
     {
         return(3857);
     }              //900913;}
     else if (coordinateSystem.ToString().Equals("Rt90_25_gon_v"))
     {
         return(3021);
     }
     else if (coordinateSystem.ToString().Equals("SWEREF99_TM"))
     {
         return(3006);
     }
     else if (coordinateSystem.ToString().Equals("SWEREF99"))
     {
         return(4378);
     }
     else if (coordinateSystem.ToString().Equals("WGS84"))
     {
         return(4326);
     }
     else if (coordinateSystem.ToString().Equals("UnKnown"))
     {
         throw new Exception("No coordinate system was supplied.");
     }
     else
     {
         throw new Exception("No coordinate system was supplied.");
     }
 }
        private List <GridCellBase> CreateGridCells(int gridCellSize, BoundingBox boundingBox, GridCoordinateSystem gridCoordinateSystem = GridCoordinateSystem.SWEREF99_TM, CoordinateSystemId displayCoordinateSystemId = CoordinateSystemId.GoogleMercator)
        {
            GridSpecification gridSpecification = new GridSpecification();

            gridSpecification.GridCellSize         = gridCellSize;
            gridSpecification.GridCoordinateSystem = gridCoordinateSystem;
            gridSpecification.BoundingBox          = boundingBox;
            CoordinateSystem    displayCoordinateSystem = new CoordinateSystem(displayCoordinateSystemId);
            GridCellManager     gridCellManager         = new GridCellManager();
            List <GridCellBase> gridCells    = gridCellManager.GenerateGrid(gridSpecification, displayCoordinateSystem);
            long calculatedNumberOfGridCells = gridCellManager.CalculateNumberOfGridCells(gridSpecification);

            Assert.AreEqual(gridCells.Count, calculatedNumberOfGridCells);
            return(gridCells);
        }