Beispiel #1
0
        public static Envelope UnprojectedExtents(Envelope extents, ICoordinateTransformation projection)
        {
            if (projection == null)
            {
                throw new ArgumentNullException("projection");
            }

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

            float[] longitudes = new float[4];
            float[] latitudes  = new float[4];


            MetersToDegrees((float)extents.getMinX(), (float)extents.getMaxY(), out longitudes[0], out latitudes[0], projection);
            MetersToDegrees((float)extents.getMinX(), (float)extents.getMinY(), out longitudes[1], out latitudes[1], projection);
            MetersToDegrees((float)extents.getMaxX(), (float)extents.getMaxY(), out longitudes[2], out latitudes[2], projection);
            MetersToDegrees((float)extents.getMaxX(), (float)extents.getMinY(), out longitudes[3], out latitudes[3], projection);

            float xMin = longitudes[0];
            float yMin = latitudes[0];
            float xMax = longitudes[0];
            float yMax = latitudes[0];

            for (int i = 0; i < 4; i++)
            {
                xMin = Math.Min(xMin, longitudes[i]);
                yMin = Math.Min(yMin, latitudes[i]);
                xMax = Math.Max(xMax, longitudes[i]);
                yMax = Math.Max(yMax, latitudes[i]);
            }

            return(new Envelope(xMin, xMax, yMin, yMax));
        }
Beispiel #2
0
        public static Envelope UnprojectedExtents( Envelope extents, ICoordinateTransformation projection )
        {
            if ( projection == null )
            {
                throw new ArgumentNullException("projection");
            }

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

            float[] longitudes = new float[4];
            float[] latitudes = new float[4];

            MetersToDegrees((float) extents.getMinX(), (float) extents.getMaxY(), out longitudes[0], out latitudes[0], projection);
            MetersToDegrees((float) extents.getMinX(), (float) extents.getMinY(), out longitudes[1], out latitudes[1], projection);
            MetersToDegrees((float) extents.getMaxX(), (float) extents.getMaxY(), out longitudes[2], out latitudes[2], projection);
            MetersToDegrees((float) extents.getMaxX(), (float) extents.getMinY(), out longitudes[3], out latitudes[3], projection);

            float xMin = longitudes[0];
            float yMin = latitudes[0];
            float xMax = longitudes[0];
            float yMax = latitudes[0];

            for ( int i = 0; i < 4; i++ )
            {
                xMin = Math.Min(xMin, longitudes[i]);
                yMin = Math.Min(yMin, latitudes[i]);
                xMax = Math.Max(xMax, longitudes[i]);
                yMax = Math.Max(yMax, latitudes[i]);
            }

            return new Envelope(xMin, xMax, yMin, yMax);
        }