Ejemplo n.º 1
0
        public static PrjEnvelope GetEnvelope(float[] srcXs, float[] srcYs, SpatialReference dstSpatialRef,
                                              Action <int, string> progressCallback)
        {
            if (dstSpatialRef == null)
            {
                dstSpatialRef = new SpatialReference("");
                dstSpatialRef.ImportFromEPSG(4326);
            }

            PrjEnvelope maskEnvelope = new PrjEnvelope(double.MinValue, double.MaxValue, double.MinValue,
                                                       double.MaxValue, dstSpatialRef);

            if (dstSpatialRef.IsGeographic() == 1) //投影目标是地理坐标
            {
                //maskEnvelope = new PrjEnvelope(-180, 180, -90, 90);
                maskEnvelope = new PrjEnvelope(-145, 180, -75, 75, dstSpatialRef);
            }
            else
            {
                ;
            } //其他投影范围未实现

            PrjEnvelope dstEnvelope = PrjEnvelope.GetEnvelope(srcXs, srcYs, maskEnvelope);

            return(dstEnvelope);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 这里面的去除噪声数据的处理,会影响到全球拼图处理中数据跨越+-180度数据的正确经纬度设置。
        /// </summary>
        /// <param name="srcXs"></param>
        /// <param name="srcYs"></param>
        /// <param name="maskEnvelope"></param>
        /// <param name="dstSpatialRef"></param>
        /// <param name="progressCallback"></param>
        /// <returns></returns>
        public static PrjEnvelope GetEnvelope(double[] srcXs, double[] srcYs, PrjEnvelope maskEnvelope,
                                              SpatialReference dstSpatialRef, Action <int, string> progressCallback)
        {
            if (dstSpatialRef == null)
            {
                dstSpatialRef = new SpatialReference("");
                dstSpatialRef.ImportFromEPSG(4326);
            }

            double noise = 0d;

            if (maskEnvelope == null)
            {
                noise = 0.001d;
                if (dstSpatialRef.IsGeographic() == 1 && maskEnvelope == null) //投影目标是地理坐标
                {
                    maskEnvelope = new PrjEnvelope(-180, 180, -90, 90, dstSpatialRef);
                    //maskEnvelope = new PrjEnvelope(-145, 180, -75, 75);
                }
                else
                {
                    maskEnvelope = new PrjEnvelope(double.MinValue, double.MaxValue, double.MinValue, double.MaxValue,
                                                   dstSpatialRef);
                    ; //...
                }
            }

            PrjEnvelope dstEnvelope        = PrjEnvelope.GetEnvelope(srcXs, srcYs, maskEnvelope);
            bool        spans180thMeridian = maskEnvelope.Width - dstEnvelope.Width < 0.011d; //(这里应当传入角度分辨率)

            if (spans180thMeridian)                                                           //跨越180度数据,不再去除噪声数据。
            {
                dstEnvelope.MinX = maskEnvelope.MinX;
                dstEnvelope.MaxX = maskEnvelope.MaxX;
            }
            else if (noise != 0d) //可以去除0.1%以下的噪声数据
            {
                dstEnvelope.MinX = dstEnvelope.MinX + dstEnvelope.Width * noise;
                dstEnvelope.MaxX = dstEnvelope.MaxX - dstEnvelope.Width * noise;
                dstEnvelope      = PrjEnvelope.GetEnvelope(srcXs, srcYs, dstEnvelope);
            }

            return(dstEnvelope);
        }