public static List <SqlGeometry> GetIndexes(SqlGeometry webMercatorGeometry, GeodeticIndexType type)
        {
            switch (type)
            {
            case GeodeticIndexType.Ncc250k:
                return(GetIndexes(webMercatorGeometry, IRI.Msh.Common.Mapping.GeodeticIndexes.Find250kIndexMbbs));

            case GeodeticIndexType.Ncc100k:
                return(GetIndexes(webMercatorGeometry, IRI.Msh.Common.Mapping.GeodeticIndexes.Find100kIndexMbbs));

            case GeodeticIndexType.Ncc50k:
                return(GetIndexes(webMercatorGeometry, IRI.Msh.Common.Mapping.GeodeticIndexes.Find50kIndexMbbs));

            case GeodeticIndexType.Ncc25k:
                return(GetIndexes(webMercatorGeometry, IRI.Msh.Common.Mapping.GeodeticIndexes.Find25kIndexMbbs));

            case GeodeticIndexType.Ncc10k:
                return(GetIndexes(webMercatorGeometry, IRI.Msh.Common.Mapping.GeodeticIndexes.Find10kIndexMbbs));

            case GeodeticIndexType.Ncc5k:
                return(GetIndexes(webMercatorGeometry, IRI.Msh.Common.Mapping.GeodeticIndexes.Find5kIndexMbbs));

            default:
                throw new NotImplementedException();
            }
        }
        public static GridDataSource Create(GeodeticIndexType indexType)
        {
            GridDataSource result = new GridDataSource();

            result.Type = indexType;

            return(result);
        }
Exemple #3
0
        public static GeodeticSheet GetIndexSheet(double longitude, double latitude, GeodeticIndexType type)
        {
            switch (type)
            {
            case GeodeticIndexType.Ncc100k:
                return(GetIndexSheet(longitude, latitude, type, _100kSize, _100kSize, Get100kSheetName));

            case GeodeticIndexType.Ncc50k:
                return(GetIndexSheet(longitude, latitude, type, _50kSize, _50kSize, Get50kSheetName));

            case GeodeticIndexType.Ncc25k:
                return(GetIndexSheet(longitude, latitude, type, _25kSize, _25kSize, Get25kSheetName));

            case GeodeticIndexType.Ncc10k:
                return(GetIndexSheet(longitude, latitude, type, _10kWidth, _10kHeight, Get10kSheetName));

            case GeodeticIndexType.Ncc5k:
                return(GetIndexSheet(longitude, latitude, type, _5kWidth, _5kHeight, Get5kSheetName));

            case GeodeticIndexType.Ncc250k:
            default:
                throw new NotImplementedException();
            }
        }
        public static List <SqlFeature> GetIndexSheets(SqlGeometry webMercatorGeometry, GeodeticIndexType type)
        {
            var geographicGeometry = webMercatorGeometry.Transform(IRI.Msh.CoordinateSystem.MapProjection.MapProjects.WebMercatorToGeodeticWgs84, 4326);

            var geographicBoundingBox = geographicGeometry.GetBoundingBox();

            return(GeodeticIndexes.FindIndexSheets(geographicBoundingBox, type)
                   .Where(b => b.GeodeticExtent.Intersects(geographicGeometry))
                   .Select(b => new SqlFeature(b.GeodeticExtent.Transform(IRI.Msh.CoordinateSystem.MapProjection.MapProjects.GeodeticWgs84ToWebMercator).AsSqlGeometry())
            {
                Attributes = new Dictionary <string, object>()
                {
                    { nameof(b.SheetName), b.SheetName }
                }
            })
                   .ToList());

            //switch (type)
            //{
            //    case GeodeticIndexType.Ncc250k:
            //        return GetIndexeSheets(webMercatorGeometry, IRI.Msh.Common.Mapping.GeodeticIndexes.Find250kIndexSheets);

            //    case GeodeticIndexType.Ncc100k:
            //        return GetIndexeSheets(webMercatorGeometry, IRI.Msh.Common.Mapping.GeodeticIndexes.Find100kIndexSheets);

            //    case GeodeticIndexType.Ncc50k:
            //        return GetIndexeSheets(webMercatorGeometry, IRI.Msh.Common.Mapping.GeodeticIndexes.Find50kIndexSheets);

            //    case GeodeticIndexType.Ncc25k:
            //        return GetIndexeSheets(webMercatorGeometry, IRI.Msh.Common.Mapping.GeodeticIndexes.Find25kIndexSheets);

            //    case GeodeticIndexType.Ncc10k:
            //        return GetIndexeSheets(webMercatorGeometry, IRI.Msh.Common.Mapping.GeodeticIndexes.Find10kIndexSheets);

            //    case GeodeticIndexType.Ncc5k:
            //        return GetIndexeSheets(webMercatorGeometry, IRI.Msh.Common.Mapping.GeodeticIndexes.Find5kIndexSheets);

            //    default:
            //        throw new NotImplementedException();
            //}
        }
Exemple #5
0
        //for 250k, 100k, 50k, 25k, 10k, 5k scales
        public static List <Geometry <Point> > GetIndexLines(BoundingBox geographicIntersectRegion, GeodeticIndexType type)
        {
            switch (type)
            {
            case GeodeticIndexType.Ncc250k:
                return(GetIndexLines(geographicIntersectRegion, _250kWidth, _250kHeight));

            case GeodeticIndexType.Ncc100k:
                return(GetIndexLines(geographicIntersectRegion, _100kSize, _100kSize));

            case GeodeticIndexType.Ncc50k:
                return(GetIndexLines(geographicIntersectRegion, _50kSize, _50kSize));

            case GeodeticIndexType.Ncc25k:
                return(GetIndexLines(geographicIntersectRegion, _25kSize, _25kSize));

            case GeodeticIndexType.Ncc10k:
                return(GetIndexLines(geographicIntersectRegion, _10kWidth, _10kHeight));

            case GeodeticIndexType.Ncc5k:
                return(GetIndexLines(geographicIntersectRegion, _5kWidth, _5kHeight));

            default:
                throw new NotImplementedException();
            }
        }
Exemple #6
0
        ////no function to calculate 250k sheet names
        //public static List<GeodeticSheet> Find250kIndexSheets(BoundingBox geographicIntersectRegion)
        //{
        //    return FindIndexes(geographicIntersectRegion, _250kWidth, _250kHeight, (minLongitude, minLatitude) => string.Empty, GeodeticIndexType.Ncc250k);
        //}

        //public static List<GeodeticSheet> Find100kIndexSheets(BoundingBox geographicIntersectRegion)
        //{
        //    return FindIndexes(geographicIntersectRegion, _100kSize, _100kSize, (minLongitude, minLatitude) => Get100kSheetName(minLongitude, minLatitude), GeodeticIndexType.Ncc100k);
        //}

        //public static List<GeodeticSheet> Find50kIndexSheets(BoundingBox geographicIntersectRegion)
        //{
        //    return FindIndexes(geographicIntersectRegion, _50kSize, _50kSize, (minLongitude, minLatitude) => Get50kSheetName(minLongitude, minLatitude), GeodeticIndexType.Ncc50k);
        //}

        //public static List<GeodeticSheet> Find25kIndexSheets(BoundingBox geographicIntersectRegion)
        //{
        //    return FindIndexes(geographicIntersectRegion, _25kSize, _25kSize, (minLongitude, minLatitude) => Get25kSheetName(minLongitude, minLatitude), GeodeticIndexType.Ncc25k);
        //}

        //public static List<GeodeticSheet> Find10kIndexSheets(BoundingBox geographicIntersectRegion)
        //{
        //    return FindIndexes(geographicIntersectRegion, _10kWidth, _10kHeight, (minLongitude, minLatitude) => Get10kSheetName(minLongitude, minLatitude), GeodeticIndexType.Ncc10k);
        //}

        //public static List<GeodeticSheet> Find5kIndexSheets(BoundingBox geographicIntersectRegion)
        //{
        //    return FindIndexes(geographicIntersectRegion, _5kWidth, _5kHeight, (minLongitude, minLatitude) => Get5kSheetName(minLongitude, minLatitude), GeodeticIndexType.Ncc5k);
        //}

        /// <summary>
        ///
        /// </summary>
        /// <param name="geographicIntersectRegion"></param>
        /// <param name="indexWidth"></param>
        /// <param name="indexHeight"></param>
        /// <param name="namingFunc">Based on Lower Left Coordinate</param>
        /// <returns></returns>
        private static List <GeodeticSheet> FindIndexes(BoundingBox geographicIntersectRegion, double indexWidth, double indexHeight, Func <double, double, string> namingFunc, GeodeticIndexType type)
        {
            if (geographicIntersectRegion.IsNaN())
            {
                geographicIntersectRegion = new BoundingBox(0, -75, 360, 75);
            }

            int startLongitude = (int)Math.Floor(geographicIntersectRegion.XMin / indexWidth);

            int endLongitude = (int)Math.Ceiling(geographicIntersectRegion.XMax / indexWidth);

            int startLatitdue = (int)Math.Floor(geographicIntersectRegion.YMin / indexHeight);

            int endLatitdue = (int)Math.Ceiling(geographicIntersectRegion.YMax / indexHeight);

            List <GeodeticSheet> result = new List <GeodeticSheet>();

            for (int i = startLongitude; i < endLongitude; i++)
            {
                for (int j = startLatitdue; j < endLatitdue; j++)
                {
                    var sheetName = namingFunc(i * indexWidth, j * indexHeight);

                    result.Add(new GeodeticSheet(new BoundingBox(i * indexWidth, j * indexHeight, (i + 1) * indexWidth, (j + 1) * indexHeight), type)
                    {
                        SheetName = sheetName
                    });
                }
            }

            return(result);
        }
Exemple #7
0
        //public static IndexSheet Get100kIndexSheet(double longitude, double latitude)
        //{
        //    var minLongitude = Math.Floor(longitude / _100kSize) * _100kSize;

        //    var minLatitude = Math.Floor(latitude / _100kSize) * _100kSize;

        //    return new IndexSheet(new BoundingBox(minLongitude, minLatitude, minLongitude + _100kSize, minLatitude + _100kSize), NccIndexType.Ncc100k)
        //    {
        //        SheetName = Get100kSheetName(minLongitude, minLatitude)
        //    };
        //}

        //public static IndexSheet Get50kIndexSheet(double longitude, double latitude)
        //{
        //    var minLongitude = Math.Floor(longitude / _50kSize) * _50kSize;

        //    var minLatitude = Math.Floor(latitude / _50kSize) * _50kSize;

        //    return new IndexSheet(new BoundingBox(minLongitude, minLatitude, minLongitude + _50kSize, minLatitude + _50kSize), NccIndexType.Ncc50k)
        //    {
        //        SheetName = Get50kSheetName(minLongitude, minLatitude)
        //    };
        //}

        //public static IndexSheet Get25kIndexSheet(double longitude, double latitude)
        //{
        //    var minLongitude = Math.Floor(longitude / _25kSize) * _25kSize;

        //    var minLatitude = Math.Floor(latitude / _25kSize) * _25kSize;

        //    return new IndexSheet(new BoundingBox(minLongitude, minLatitude, minLongitude + _25kSize, minLatitude + _25kSize), NccIndexType.Ncc25k)
        //    {
        //        SheetName = Get25kSheetName(minLongitude, minLatitude)
        //    };
        //}

        //public static IndexSheet Get10kIndexSheet(double longitude, double latitude)
        //{
        //    var minLongitude = Math.Floor(longitude / _10kWidth) * _10kWidth;

        //    var minLatitude = Math.Floor(latitude / _10kHeight) * _10kHeight;

        //    return new IndexSheet(new BoundingBox(minLongitude, minLatitude, minLongitude + _10kWidth, minLatitude + _10kHeight), NccIndexType.Ncc10k)
        //    {
        //        SheetName = Get10kSheetName(minLongitude, minLatitude)
        //    };
        //}

        //public static IndexSheet Get5kIndexSheet(double longitude, double latitude)
        //{
        //    var minLongitude = Math.Floor(longitude / _5kWidth) * _5kWidth;

        //    var minLatitude = Math.Floor(latitude / _5kHeight) * _5kHeight;

        //    return new IndexSheet(new BoundingBox(minLongitude, minLatitude, minLongitude + _5kWidth, minLatitude + _5kHeight), NccIndexType.Ncc5k)
        //    {
        //        SheetName = Get5kSheetName(minLongitude, minLatitude)
        //    };
        //}

        //2k, 1k, 500

        //public static IndexSheet Get2kIndexBlock(double longitude, double latitude, int utmZone)
        //{
        //    var utmSheet = UtmSheet.Create2kUtmBlock(longitude, latitude, utmZone);

        //    return new IndexSheet(utmSheet.GeodeticExtent, NccIndexType.NccUtmBased2kBlock) { SheetName = utmSheet.Title };
        //}

        //public static UtmSheet Get2kUtmBlock(double longitude, double latitude, int utmZone)
        //{
        //    return UtmSheet.Create2kUtmBlock(longitude, latitude, utmzone);
        //    //var utmPoint = MapProjects.GeodeticToUTM(new Point(longitude, latitude), Ellipsoids.WGS84, utmZone);

        //    //if (!_2kUtmBoudingBox.Intersects(utmPoint))
        //    //{
        //    //    return null;
        //    //}

        //    //var column = (int)Math.Floor((utmPoint.X - _2kUtmXmin) / _2kUtmBlockWidth);

        //    //var row = (int)Math.Floor((_2kUtmYmax - utmPoint.Y) / _2kUtmBlockHeight);

        //    //return UtmSheet.Create2kBlock(row, column, utmZone);

        //    //return new IndexSheet(geoBound, NccIndexType.NccUtmBased2kBlock) { SheetName = $"{utmZone.ToString("00")}{column}{row.ToString("00")}" };
        //}

        //public static UtmSheet Get2kUtmSheet(double longitude, double latitude, int utmZone)
        //{
        //    var utmPoint = MapProjects.GeodeticToUTM(new Point(longitude, latitude), Ellipsoids.WGS84, utmZone);

        //    if (!_2kUtmBoudingBox.Intersects(utmPoint))
        //    {
        //        return null;
        //    }

        //    var blockColumnRow = CalculateRowColumn(_2kUtmBoudingBox, utmPoint, _2kUtmBlockWidth, _2kUtmBlockHeight);

        //    var blockBound = CalculateUtm2kBlockBoundingBox((int)blockColumnRow.Y, (int)blockColumnRow.X);

        //    var sheetColumnRow = CalculateRowColumn(blockBound, utmPoint, _2kUtmSheetWidth, _2kUtmSheetHeight);

        //    var geoBound = CalculateUtm2kBlockBoundingBox((int)sheetColumnRow.Y, (int)sheetColumnRow.X)
        //                    .Transform(p => MapProjects.UTMToGeodetic(p, utmZone));

        //    return new UtmSheet(geoBound, NccIndexType.NccUtmBased2kSheet)
        //    {
        //        SheetName = $"{utmZone.ToString("00")}{_2kUtmBlockColumns[(int)blockColumnRow.X]}{blockColumnRow.Y.ToString("00")}{_2kUtmSheetColumns[(int)sheetColumnRow.X]}{sheetColumnRow.Y.ToString("00")}"
        //    };
        //}


        //private static BoundingBox CalculateUtm2kBlockBoundingBox(int row, int column)
        //{
        //    return new BoundingBox(_2kUtmXmin + column * _2kUtmBlockWidth,
        //                                _2kUtmYmax - (row + 1) * _2kUtmBlockHeight,
        //                                _2kUtmXmin + (column + 1) * _2kUtmBlockWidth,
        //                                _2kUtmYmax - row * _2kUtmBlockHeight);
        //}

        //private static Point CalculateRowColumn(BoundingBox utmBoundingBox, Point utmPoint, double columnWidth, double rowHeight)
        //{
        //    if (!utmBoundingBox.Intersects(utmPoint))
        //    {
        //        return null;
        //    }

        //    var column = Math.Floor((utmPoint.X - utmBoundingBox.XMin) / columnWidth);

        //    var row = Math.Floor((utmBoundingBox.YMax - utmPoint.Y) / rowHeight);

        //    return new Point(column, row);
        //}

        ////for 1:1000 and 1:500 sheets
        //private static int? CalculateMapNumber(BoundingBox utmSheetBoundingBox, Point utmPoint)
        //{
        //    if (!utmSheetBoundingBox.Intersects(utmPoint))
        //        return null;

        //    var center = utmSheetBoundingBox.Center;

        //    if (utmPoint.X >= center.X)
        //    {
        //        if (utmPoint.Y >= center.Y)
        //        {
        //            return 1;
        //        }
        //        else
        //        {
        //            return 2;
        //        }
        //    }
        //    else
        //    {
        //        if (utmPoint.Y >= center.Y)
        //        {
        //            return 4;
        //        }
        //        else
        //        {
        //            return 3;
        //        }
        //    }
        //}

        #endregion


        #region Get IndexSheets in a Region (BoundingBox > List<IndexSheet>)

        public static List <GeodeticSheet> FindIndexSheets(BoundingBox geographicIntersectRegion, GeodeticIndexType type)
        {
            switch (type)
            {
            //no function to calculate 250k sheet names
            case GeodeticIndexType.Ncc250k:
                return(FindIndexes(geographicIntersectRegion, _250kWidth, _250kHeight, (minLongitude, minLatitude) => string.Empty, GeodeticIndexType.Ncc250k));

            case GeodeticIndexType.Ncc100k:
                return(FindIndexes(geographicIntersectRegion, _100kSize, _100kSize, (minLongitude, minLatitude) => Get100kSheetName(minLongitude, minLatitude), GeodeticIndexType.Ncc100k));

            case GeodeticIndexType.Ncc50k:
                return(FindIndexes(geographicIntersectRegion, _50kSize, _50kSize, (minLongitude, minLatitude) => Get50kSheetName(minLongitude, minLatitude), GeodeticIndexType.Ncc50k));

            case GeodeticIndexType.Ncc25k:
                return(FindIndexes(geographicIntersectRegion, _25kSize, _25kSize, (minLongitude, minLatitude) => Get25kSheetName(minLongitude, minLatitude), GeodeticIndexType.Ncc25k));

            case GeodeticIndexType.Ncc10k:
                return(FindIndexes(geographicIntersectRegion, _10kWidth, _10kHeight, (minLongitude, minLatitude) => Get10kSheetName(minLongitude, minLatitude), GeodeticIndexType.Ncc10k));

            case GeodeticIndexType.Ncc5k:
                return(FindIndexes(geographicIntersectRegion, _5kWidth, _5kHeight, (minLongitude, minLatitude) => Get5kSheetName(minLongitude, minLatitude), GeodeticIndexType.Ncc5k));

            default:
                throw new NotImplementedException();
            }
        }
Exemple #8
0
        private static GeodeticSheet GetIndexSheet(double longitude, double latitude, GeodeticIndexType type, double width, double height, Func <double, double, string> namingFunc)
        {
            var minLongitude = Math.Floor(longitude / width) * width;

            var minLatitude = Math.Floor(latitude / height) * height;

            return(new GeodeticSheet(new BoundingBox(minLongitude, minLatitude, minLongitude + width, minLatitude + height), type)
            {
                SheetName = namingFunc(minLongitude, minLatitude)
            });
        }