当前位置: 首页>>代码示例>>C#>>正文


C# Extent.ToEnvelope方法代码示例

本文整理汇总了C#中DotSpatial.Data.Extent.ToEnvelope方法的典型用法代码示例。如果您正苦于以下问题:C# Extent.ToEnvelope方法的具体用法?C# Extent.ToEnvelope怎么用?C# Extent.ToEnvelope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DotSpatial.Data.Extent的用法示例。


在下文中一共展示了Extent.ToEnvelope方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Select

        /// <inheritdoc/>
        public virtual List<IFeature> Select(Extent region, out Extent affectedRegion)
        {
            var result = new List<IFeature>();
            affectedRegion = new Extent();

            if (IndexMode)
            {
                var aoi = new ShapeRange(region);
                var shapes = ShapeIndices;
                for (var shp = 0; shp < shapes.Count; shp++)
                {
                    if (!shapes[shp].Intersects(aoi))
                    {
                        continue;
                    }

                    var feature = GetFeature(shp);
                    affectedRegion.ExpandToInclude(feature.Envelope.ToExtent());
                    result.Add(feature);
                }
            }
            else
            {
                foreach (var feature in Features)
                {
                    if (!region.Intersects(feature.Envelope) ||
                       !feature.Intersects(region.ToEnvelope()))
                    {
                        continue;
                    }
                  
                    result.Add(feature);
                    affectedRegion.ExpandToInclude(feature.Envelope.ToExtent());
                }
            }

            return result;
        }
开发者ID:hanchao,项目名称:DotSpatial,代码行数:39,代码来源:FeatureSet.cs

示例2: Select

        /// <inheritdoc/>
        public virtual List<IFeature> Select(Extent region, out Extent affectedRegion)
        {
            List<IFeature> result = new List<IFeature>();
            if (IndexMode)
            {
                ShapeRange aoi = new ShapeRange(region);
                Extent affected = new Extent();
                List<ShapeRange> shapes = ShapeIndices;
                if (shapes != null)
                {
                    //ProgressMeter = new ProgressMeter(ProgressHandler, "Selecting shapes", shapes.Count);
                    for (int shp = 0; shp < shapes.Count; shp++)
                    {
                        //ProgressMeter.Next();
                        if (!shapes[shp].Intersects(aoi))
                        {
                            continue;
                        }

                        IFeature f = GetFeature(shp);
                        affected.ExpandToInclude(shapes[shp].Extent);
                        result.Add(f);
                    }
                    //ProgressMeter.Reset();
                }

                affectedRegion = affected;
                return result;
            }

            affectedRegion = new Extent();

            bool useProgress = (Features.Count > 10000);
            //ProgressMeter = new ProgressMeter(ProgressHandler, "Selecting Features", Features.Count);
            foreach (IFeature feature in Features)
            {
                //if (useProgress)
                //    ProgressMeter.Next();
                if (!region.Intersects(feature.Envelope))
                {
                    continue;
                }
                if (!feature.Intersects(region.ToEnvelope()))
                {
                    continue;
                }
                result.Add(feature);
                affectedRegion.ExpandToInclude(feature.Envelope.ToExtent());
            }
            //if (useProgress)
            //    ProgressMeter.Reset();

            return result;
        }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:55,代码来源:FeatureSet.cs

示例3: GetBitmap

        /// <summary>
        /// For big images the scale that is just one step larger than the specified window will be used.
        /// </summary>
        /// <param name="envelope"></param>
        /// <param name="window"></param>
        /// <returns></returns>
        public override Bitmap GetBitmap(Extent envelope, Rectangle window)
        {
            if (window.Width == 0 || window.Height == 0) return null;
            if (_header == null) return null;
            if (_header.ImageHeaders == null) return null;
            if (_header.ImageHeaders[0] == null) return null;

            Rectangle expWindow = window.ExpandBy(1);
            IEnvelope expEnvelope = envelope.ToEnvelope().Reproportion(window, expWindow);

            IEnvelope env = expEnvelope.Intersection(Bounds.Extent.ToEnvelope());
            if (env == null || env.IsNull || env.Height == 0 || env.Width == 0) return null;

            PyramidImageHeader he = _header.ImageHeaders[0];
            int scale;

            double cwa = expWindow.Width / expEnvelope.Width;
            double cha = expWindow.Height / expEnvelope.Height;

            for (scale = 0; scale < _header.ImageHeaders.Length; scale++)
            {
                PyramidImageHeader ph = _header.ImageHeaders[scale];

                if (cwa > ph.NumColumns / Bounds.Width || cha > ph.NumRows / Bounds.Height)
                {
                    if (scale > 0) scale -= 1;
                    break;
                }
                he = ph;
            }

            RasterBounds overviewBounds = new RasterBounds(he.NumRows, he.NumColumns, he.Affine);
            Rectangle r = overviewBounds.CellsContainingExtent(envelope);
            if (r.Width == 0 || r.Height == 0) return null;
            byte[] vals = ReadWindow(r.Y, r.X, r.Height, r.Width, scale);
            Bitmap bmp = new Bitmap(r.Width, r.Height);
            BitmapData bData = bmp.LockBits(new Rectangle(0, 0, r.Width, r.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
            Marshal.Copy(vals, 0, bData.Scan0, vals.Length);
            bmp.UnlockBits(bData);

            // Use the cell coordinates to determine the affine coefficients for the cells retrieved.
            double[] affine = new double[6];
            Array.Copy(he.Affine, affine, 6);
            affine[0] = affine[0] + r.X * affine[1] + r.Y * affine[2];
            affine[3] = affine[3] + r.X * affine[4] + r.Y * affine[5];

            if (window.Width == 0 || window.Height == 0)
            {
                return null;
            }

            Bitmap result = new Bitmap(window.Width, window.Height);
            Graphics g = Graphics.FromImage(result);

            //

            // Gets the scaling factor for converting from geographic to pixel coordinates
            double dx = (window.Width / envelope.Width);
            double dy = (window.Height / envelope.Height);

            double[] a = affine;

            // gets the affine scaling factors.
            float m11 = Convert.ToSingle(a[1] * dx);
            float m22 = Convert.ToSingle(a[5] * -dy);
            float m21 = Convert.ToSingle(a[2] * dx);
            float m12 = Convert.ToSingle(a[4] * -dy);
            float l = (float)(a[0] - .5 * (a[1] + a[2])); // Left of top left pixel
            float t = (float)(a[3] - .5 * (a[4] + a[5])); // top of top left pixel
            float xShift = (float)((l - envelope.MinX) * dx);
            float yShift = (float)((envelope.MaxY - t) * dy);
            g.Transform = new Matrix(m11, m12, m21, m22, xShift, yShift);
            g.PixelOffsetMode = PixelOffsetMode.Half;
            if (m11 > 1 || m22 > 1)
            {
                g.InterpolationMode = InterpolationMode.NearestNeighbor;
            }

            g.DrawImage(bmp, new PointF(0, 0));
            bmp.Dispose();
            g.Dispose();
            return result;
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:89,代码来源:PyramidImage.cs

示例4: ResetAspectRatio

        /// <summary>
        /// If a BackBuffer.Extents exists, this will enlarge those extents to match the aspect ratio
        /// of the pixel view.  If one doesn't exist, the _mapFrame.Extents will be used instead.
        /// </summary>
        /// <param name="newEnv">The envelope to adjust</param>
        protected void ResetAspectRatio(Extent newEnv)
        {

            // ---------- Aspect Ratio Handling
            if (newEnv == null) return;
            double h = View.Height;
            double w = View.Width;
            // It isn't exactly an exception, but rather just an indication not to do anything here.
            if (h == 0 || w == 0) return;

            double controlAspect = w / h;
            double envelopeAspect = newEnv.Width / newEnv.Height;
            Coordinate center = newEnv.ToEnvelope().Center();

            if (controlAspect > envelopeAspect)
            {
                // The Control is proportionally wider than the envelope to display.
                // If the envelope is proportionately wider than the control, "reveal" more width without
                // changing height If the envelope is proportionately taller than the control,
                // "hide" width without changing height
                newEnv.SetCenter(center, newEnv.Height * controlAspect, newEnv.Height);
            }
            else
            {
                // The control is proportionally taller than the content is
                // If the envelope is proportionately wider than the control,
                // "hide" the extra height without changing width
                // If the envelope is proportionately taller than the control, "reveal" more height without changing width
                newEnv.SetCenter(center, newEnv.Width, newEnv.Width / controlAspect);
            }

        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:37,代码来源:GDIMapFrame.cs

示例5: RaiseCallbackEvent

        public void RaiseCallbackEvent(String eventArgument)
//        public virtual void RaiseCallbackEvent(String eventArgument)  //to override in subclass
        {
//            returnCommand = "REFRESH";  //unsightly refresh when change legend selection
            returnCommand = "NOTHING";

//            string Nm = SessionName;  //not used

            GDIMap m = (GDIMap)System.Web.HttpContext.Current.Session[(string)ViewState[ClientID]];

            if (m == null) return;

                string[] arg = eventArgument.Split('|');

                string cmd = arg[0].ToUpper();

                switch (cmd)
                {
                    case "ZOOMALL":
                        {
                            ZoomAll(ref m);
                            returnCommand = "REFRESHANDHIDEBUFFER";
                        }
                        break;

                    case "SELECT":
                        {
                            if (m.Layers.SelectedLayer != null)
                            {
                                System.Drawing.Point pt1 = new System.Drawing.Point(Convert.ToInt32(arg[1]), Convert.ToInt32(arg[2]));
                                System.Drawing.Point pt2 = new System.Drawing.Point(Convert.ToInt32(arg[3]), Convert.ToInt32(arg[4]));

                                Coordinate pm1 = m.PixelToProj(pt1);
                                Coordinate pm2 = m.PixelToProj(pt2);

                                Extent ex = new Extent(Math.Min(pm1.X, pm2.X), Math.Min(pm1.Y, pm2.Y),
                                                       Math.Max(pm1.X, pm2.X), Math.Max(pm1.Y, pm2.Y));

                                IEnvelope MapEnv = m.Extent.ToEnvelope();

                                m.Layers.SelectedLayer.ClearSelection(out MapEnv);


                                m.Layers.SelectedLayer.ClearSelection();

                                IEnvelope affectedarea = null;

//                                m.Layers.SelectedLayer.Select(m.ViewExtents.ToEnvelope(), ex.ToEnvelope(), Symbology.SelectionMode.IntersectsExtent, out affectedarea);
                                m.Layers.SelectedLayer.Select(ex.ToEnvelope(), ex.ToEnvelope(), Symbology.SelectionMode.Intersects, out affectedarea);

                                returnCommand = "STRUCTURE";

                            }
                            else
                            {
                                returnValue = "<table><tr><td>Select a layer first.<p></td></tr><table>";
                                returnCommand = "POPUP";
//                                returnValue = "Select a layer first.";
//                                returnCommand = "ALERT";
                            }

                        }
                        break;

                    case "INFO":
                        {

                            System.Drawing.Point pt = new System.Drawing.Point(Convert.ToInt32(arg[2]), Convert.ToInt32(arg[3]));
                            Coordinate pm = m.PixelToProj(pt);

                            Extent ex = new Extent(pm.X, pm.Y, pm.X, pm.Y);

                            if (m.Layers.SelectedLayer != null)
                            {
                                FeatureSet fs = m.Layers.SelectedLayer.DataSet as FeatureSet;

//                                List<IFeature> flist = fs.Select(ex);  //returns empty list when IndexMode == false
                                List<int> flist = fs.SelectIndices(ex);

                                int n = flist.Count;

//                                returnValue = "<table border='1'>";  //looks goofy
                                returnValue = "<table>";

                                if (n > 0)
                                {
                                    for (int i = 0; i < fs.DataTable.Columns.Count; i++)
                                    {
                                        returnValue += "<tr><td>" + fs.DataTable.Columns[i].ColumnName + 
//                                                       "</td><td>" + flist[0].DataRow[i].ToString() + "</td></tr>";
                                                       "</td><td>" + fs.GetFeature(flist[0]).DataRow[i].ToString() + "</td></tr>";
                                    }

                                    returnValue += "</table>";
                                    returnCommand = "POPUP";
                                }
                            }
                            else
                            {
                                returnValue = "<table><tr><td>Select a layer first.<p></td></tr><table>";
//.........这里部分代码省略.........
开发者ID:hanchao,项目名称:DotSpatial,代码行数:101,代码来源:WebMap.cs

示例6: RaiseCallbackEvent

        public void RaiseCallbackEvent(String eventArgument)
        {
            returnCommand = "REFRESH";

            string Nm = SessionName;

            GDIMap m = (GDIMap)System.Web.HttpContext.Current.Session[(string)ViewState[ClientID]];

            if (m == null) return;


                string[] arg = eventArgument.Split('|');

                string cmd = arg[0].ToUpper();

                switch (cmd)
                {
                    case "ZOOMALL":
                        {
                            ZoomAll(ref m);
                            returnCommand = "REFRESHANDHIDEBUFFER";
                        }
                        break;

                    case "SELECT":
                        {
                            if (m.Layers.SelectedLayer != null)
                            {
                                System.Drawing.Point pt1 = new System.Drawing.Point(Convert.ToInt32(arg[1]), Convert.ToInt32(arg[2]));
                                System.Drawing.Point pt2 = new System.Drawing.Point(Convert.ToInt32(arg[3]), Convert.ToInt32(arg[4]));

                                Coordinate pm1 = m.PixelToProj(pt1);
                                Coordinate pm2 = m.PixelToProj(pt2);

                                Extent ex = new Extent(Math.Min(pm1.X, pm2.X), Math.Min(pm1.Y, pm2.Y),
                                                       Math.Max(pm1.X, pm2.X), Math.Max(pm1.Y, pm2.Y));

                                IEnvelope MapEnv = m.Extent.ToEnvelope();

                                m.Layers.SelectedLayer.ClearSelection(out MapEnv);


                                m.Layers.SelectedLayer.ClearSelection();

                                IEnvelope affectedarea = null;

                                m.Layers.SelectedLayer.Select(m.ViewExtents.ToEnvelope(), ex.ToEnvelope(), Symbology.SelectionMode.IntersectsExtent, out affectedarea);

                                returnCommand = "STRUCTURE";

                            }
                            else
                            {
                                returnValue = "<table><tr><td> Choose a layer! </td></tr><table>";
                                returnCommand = "POPUP";
                            }

                        }
                        break;

                    case "INFO":
                        {

                            System.Drawing.Point pt = new System.Drawing.Point(Convert.ToInt32(arg[2]), Convert.ToInt32(arg[3]));
                            Coordinate pm = m.PixelToProj(pt);

                            Extent ex = new Extent(pm.X, pm.Y, pm.X, pm.Y);

                            if (m.Layers.SelectedLayer != null)
                            {
                                FeatureSet fs = m.Layers.SelectedLayer.DataSet as FeatureSet;

                                List<IFeature> flist = fs.Select(ex);

                                int n = flist.Count;

                                returnValue = "<table>";

                                if (n > 0)
                                {
                                    for (int i = 0; i < fs.DataTable.Columns.Count; i++)
                                    {
                                        returnValue += "<tr><td>" + fs.DataTable.Columns[i].ColumnName + "</td><td>" + flist[0].DataRow[i].ToString() + "</td></tr>";
                                    }

                                    returnValue += "</table>";
                                    returnCommand = "POPUP";
                                }
                            }
                            else
                            {
                                returnValue = "<table><tr><td> Select a layer before info !</td></tr><table>";
                                returnCommand = "POPUP";
                            }
                        }
                        break;


                    case "RESIZE":
                        {
//.........这里部分代码省略.........
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:101,代码来源:WebMap.cs


注:本文中的DotSpatial.Data.Extent.ToEnvelope方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。