Utility class for projecting coordinates from geographic (4326) to web mercator (102100) and back.
Example #1
0
        public static IEnvelope GetEnvelopeFromZoomRowCol(int zoom, int row, int col)
        {
            IEnvelope e = new EnvelopeClass();

            e.SpatialReference = GetSpatialReference(102100);
            IPoint llupperLeftPoint  = TileToGeographic(col, row, zoom);
            IPoint lllowerRightPoint = TileToGeographic(col + 1, row + 1, zoom);

            var    upperLeftPtWm    = WebMercatorUtil.GeographicToWebMercator(llupperLeftPoint.Y, llupperLeftPoint.X);
            IPoint wmUpperLeftPoint = new PointClass();

            wmUpperLeftPoint.X = upperLeftPtWm.X;
            wmUpperLeftPoint.Y = upperLeftPtWm.Y;

            var    lowerRightPtWm    = WebMercatorUtil.GeographicToWebMercator(lllowerRightPoint.Y, lllowerRightPoint.X);
            IPoint wmLowerRightPoint = new PointClass();

            wmLowerRightPoint.X = lowerRightPtWm.X;
            wmLowerRightPoint.Y = lowerRightPtWm.Y;

            e.UpperLeft  = wmUpperLeftPoint;
            e.LowerRight = wmLowerRightPoint;
            return(e);
        }