Exemplo n.º 1
0
        public System.Drawing.Rectangle GetRasterRect()
        {
            IRasterDrawing rst = _canvas.PrimaryDrawObject as IRasterDrawing;

            if (rst == null)
            {
                return(Rectangle.Empty);
            }
            GeoDo.RSS.Core.DrawEngine.CoordEnvelope retRect = null;
            foreach (object obj in _aoiContainer.AOIs)
            {
                GeoDo.RSS.Core.DrawEngine.CoordEnvelope rect = null;
                if (obj is GeometryOfDrawed)
                {
                    rect = GetRasterRect(obj as GeometryOfDrawed);
                }
                else if (obj is Feature)
                {
                    rect = GetRasterRect(obj as Feature);
                }
                if (rect == null)
                {
                    continue;
                }
                if (retRect == null)
                {
                    retRect = rect;
                }
                else
                {
                    retRect = retRect.Union(rect);
                }
            }
            return(new Rectangle((int)retRect.MinX, (int)retRect.MinY, (int)retRect.Width, (int)retRect.Height));
        }
Exemplo n.º 2
0
 //获取多个aoi的外接矩形
 private GeoDo.RSS.Core.DrawEngine.CoordEnvelope GetGeoRect()
 {
     GeoDo.RSS.Core.DrawEngine.CoordEnvelope retRect = null;
     foreach (object obj in _aoiContainer.AOIs)
     {
         string name;
         GeoDo.RSS.Core.DrawEngine.CoordEnvelope rect = null;
         rect = GetGeoRect(obj as Feature, out name);
         if (rect == null)
         {
             continue;
         }
         if (retRect == null)
         {
             retRect = rect;
         }
         else
         {
             retRect = retRect.Union(rect);
         }
     }
     return(retRect);
 }
Exemplo n.º 3
0
        public GeoDo.RSS.Core.DrawEngine.CoordEnvelope GetGeoRect()
        {
            IRasterDrawing rst = _canvas.PrimaryDrawObject as IRasterDrawing;

            if (rst == null)
            {
                return(null);
            }
            GeoDo.RSS.Core.DrawEngine.CoordEnvelope retRect = null;
            foreach (object obj in _aoiContainer.AOIs)
            {
                string name;
                GeoDo.RSS.Core.DrawEngine.CoordEnvelope rect = null;
                if (obj is GeometryOfDrawed)
                {
                    rect = GetGeoRect(obj as GeometryOfDrawed);
                }
                else if (obj is Feature)
                {
                    rect = GetGeoRect(obj as Feature, out name);
                }
                if (rect == null)
                {
                    continue;
                }
                if (retRect == null)
                {
                    retRect = rect;
                }
                else
                {
                    retRect = retRect.Union(rect);
                }
            }
            return(retRect);
        }
Exemplo n.º 4
0
        private static BitmapObject[] GetBitmapObjects(string[] fnames, int maxSize, ICanvas canvas, out Size bmpSize,
                                                       out Size dataSize, out GeoDo.RSS.Core.DrawEngine.CoordEnvelope viewPrjEvp,
                                                       out GeoDo.RSS.Core.DF.CoordEnvelope viewGeoEvp,
                                                       out float resolution)
        {
            bmpSize    = Size.Empty;
            dataSize   = new Size();
            viewPrjEvp = null;
            viewGeoEvp = null;
            resolution = 0;
            List <BitmapObject> bmpObjs = new List <BitmapObject>();
            BitmapObject        bmpO;

            GeoDo.RSS.Core.DrawEngine.CoordEnvelope drawEvp = null;
            bool isFirst = true;

            foreach (string fname in fnames)
            {
                if (!File.Exists(fname))
                {
                    continue;
                }
                using (IRasterDataProvider prd = GeoDataDriver.Open(fname) as IRasterDataProvider)
                {
                    IOverviewGenerator ov = prd as IOverviewGenerator;
                    bmpSize = ov.ComputeSize(maxSize);
                    Bitmap         bmp      = new Bitmap(bmpSize.Width, bmpSize.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                    RasterIdentify identify = new RasterIdentify(fname);
                    object[]       sts      = GetColorTableFunc(prd, identify.ProductIdentify, identify.SubProductIdentify);
                    if (sts != null)
                    {
                        ov.Generate(new int[] { 1, 1, 1 }, sts, ref bmp);
                    }
                    else
                    {
                        int[] bands = prd.GetDefaultBands();
                        if (bands == null || bands.Length == 0)
                        {
                            return(null);
                        }
                        ov.Generate(bands, ref bmp);
                    }
                    drawEvp = GetDrawingEnvelop(canvas, prd);
                    if (isFirst)
                    {
                        viewPrjEvp = drawEvp;
                        ICoordinateTransform tans = canvas.CoordTransform;
                        viewGeoEvp = PrjToGeoCoordEvp(viewPrjEvp, tans);
                        resolution = prd.ResolutionX;
                        dataSize   = GetMaxDataSize(canvas, viewPrjEvp, prd, out viewGeoEvp);
                        isFirst    = false;
                    }
                    else
                    {
                        viewPrjEvp = viewPrjEvp.Union(drawEvp);
                        dataSize   = GetMaxDataSize(canvas, viewPrjEvp, prd, out viewGeoEvp);
                        //如果分辩率不相等则取最大的分辨率
                        if (resolution < prd.ResolutionX)
                        {
                            resolution = prd.ResolutionX;
                        }
                    }
                    bmpO = new BitmapObject(bmp, drawEvp);
                    bmpObjs.Add(bmpO);
                }
            }
            return(bmpObjs.Count != 0 ? bmpObjs.ToArray() : null);
        }