예제 #1
2
파일: frmGrid.cs 프로젝트: qlands/GOBLET
        // calculates extent (bounding box) of shapefile layer -
        // the extent is slightly larger than original shapefile extent:
        // values are rounded to whole pixels
        private MapWinGIS.Extents calcShapefileExtent(MapWinGIS.Shapefile shp)
        {
            double cellSize = m_DefaultCellSize;

            Utils.string2double(txtCellSize.Text, out cellSize);

            MapWinGIS.Extents ext = shp.Extents;

            double xMin = ((int)(ext.xMin / cellSize)) * cellSize;
            double yMin = ((int)(ext.yMin / cellSize)) * cellSize;

            int nCols = ((int)( (ext.xMax - ext.xMin) / cellSize )) + 1;
            lblNumberCols.Text = nCols.ToString();

            int nRows = ((int)( (ext.yMax - ext.yMin) / cellSize )) + 1;
            lblNumberRows.Text = nRows.ToString();

            double xMax = xMin + nCols * cellSize;
            double yMax = yMin + nRows * cellSize;

            MapWinGIS.Extents newExtents = new MapWinGIS.Extents();
            newExtents.SetBounds(xMin, yMin, 0, xMax, yMax, 0);
            return newExtents;
        }
예제 #2
0
        public static void SelectCalle(PointD p1, PointD p2, string nombre, string tipo)
        {
            if (LMapa == null)
            {
                return;
            }
            MapWinGIS.Extents ex = new MapWinGIS.Extents();
            object            x  = new object();

            ex.SetBounds(p1.X, p1.Y, 0, p2.X, p2.Y, 0);
            ((MapWinGIS.Shapefile)LMapa.GetObject()).SelectShapes(ex, 0, MapWinGIS.SelectMode.INTERSECTION, ref x);
            int[] shapes = x as int[];
            //limpiar calle anterior
            if (CalleSeleccionada != null)
            {
                foreach (int shape in CalleSeleccionada)
                {
                    LMapa.Shapes[shape].Color = LMapa.Color;
                }
            }
            List <int> l = new List <int>();

            foreach (int shape in shapes)
            {
                if (((MapWinGIS.Shapefile)LMapa.GetObject()).get_CellValue(IndexNombre, shape).ToString() == nombre && ((MapWinGIS.Shapefile)LMapa.GetObject()).get_CellValue(IndexTipo, shape).ToString() == tipo)
                {
                    l.Add(shape);
                    LMapa.Shapes[shape].Color = System.Drawing.Color.Red;
                }
            }
            CalleSeleccionada = l.Count == 0 ? null : l.ToArray();
        }
예제 #3
0
        /// <summary>
        /// 更新当前的红色矩形盒
        /// </summary>
        internal void UpdateLocatorBox()
        {
            Program.frmMain.MapPreview.ZoomToMaxExtents();

            MapWinGIS.Extents exts      = (MapWinGIS.Extents)Program.frmMain.MapMain.Extents;
            double            newLeft   = 0;;
            double            newRight  = 0;
            double            newTop    = 0;
            double            newBottom = 0;

            if (m_ShowLocatorBox == false) //不显示红色方框盒子,则清空返回
            {
                Program.frmMain.MapPreview.ClearDrawings();
                return;
            }

            //获取盒子线条宽度
            Program.frmMain.MapPreview.ProjToPixel(exts.xMin, exts.yMax, ref newLeft, ref newTop);
            Program.frmMain.MapPreview.ProjToPixel(exts.xMax, exts.yMin, ref newRight, ref newBottom);

            try
            {
                g_ExtentsRect = new System.Drawing.Rectangle((int)newLeft, (int)newTop, System.Convert.ToInt32(newRight - newLeft), System.Convert.ToInt32(newBottom - newTop));

                DrawBox(g_ExtentsRect);//绘制
            }
            catch
            {
                //忽略这个异常,因为可能范围溢出
            }
        }
예제 #4
0
        public DVInfo this[int LayerHandle]
        {
            get
            {
                if (!ht.ContainsKey(LayerHandle))
                {
                    MapWinGIS.Extents emptyexts = new MapWinGIS.Extents();
                    emptyexts.SetBounds(0, 0, 0, 0, 0, 0);
                    Add(LayerHandle, emptyexts, false);
                }

                return((DVInfo)(ht[LayerHandle]));
            }
            set
            {
                if (ht.ContainsKey(LayerHandle))
                {
                    ht[LayerHandle] = value;
                }
                else
                {
                    ht.Add(LayerHandle, value);
                }
            }
        }
예제 #5
0
 public LabelInfo(bool UseZoomLevel, double xMin, double yMin, double xMax, double yMax)
 {
     extents = new MapWinGIS.Extents();
     extents.SetBounds(xMin, yMin, 0, xMax, yMax, 0);
     scale           = Program.frmMain.ExtentsToScale(extents);
     UseMinZoomLevel = UseZoomLevel;
 }
예제 #6
0
        /// <summary>
        /// 根据在屏幕中划定的范围搜索shapes
        /// </summary>
        /// <param name="screenLeft">相对屏幕的左坐标点</param>
        /// <param name="screenRight">相对屏幕的右坐标点</param>
        /// <param name="screenTop">相对屏幕的顶部坐标点</param>
        /// <param name="screenBottom">相对屏幕的底部坐标点</param>
        /// <param name="ctrlDown"></param>
        /// <returns></returns>
        internal MapWinGIS.Interfaces.SelectInfo SelectShapesByRectangle(int screenLeft, int screenRight, int screenTop, int screenBottom, bool ctrlDown = false)
        {
            if (Program.frmMain.Legend.SelectedLayer == -1)
            {
                return(null);
            }

            Interfaces.eLayerType type = Program.frmMain.Layers[Program.frmMain.Layers.CurrentLayer].LayerType;
            if (type == Interfaces.eLayerType.Grid || type == Interfaces.eLayerType.Image || type == Interfaces.eLayerType.Invalid)
            {
                return(null);
            }

            MapWinGIS.Shapefile sf = (MapWinGIS.Shapefile)(Program.frmMain.MapMain.get_GetObject(Program.frmMain.Layers.CurrentLayer));

            double geoL = 0, geoR = 0, geoT = 0, geoB = 0;

            Program.frmMain.MapMain.PixelToProj(screenLeft, screenTop, ref geoL, ref geoT);
            Program.frmMain.MapMain.PixelToProj(screenRight, screenBottom, ref geoR, ref geoB);

            MapWinGIS.Extents bounds = new MapWinGIS.Extents();
            bounds.SetBounds(geoL, geoB, 0, geoR, geoT, 0);

            if (ctrlDown)
            {
                m_SelectionOperation = Interfaces.SelectionOperation.SelectAdd;
            }
            else
            {
                m_SelectionOperation = Interfaces.SelectionOperation.SelectNew;
            }

            return(PerformSelection(sf, bounds, 0.0D));
        }
예제 #7
0
        private void DibujarGrifos(PointD ubicacion)
        {
            // modificado para dibujar centro y desplegar grifos sin hacer zoom
            // centrar en llamado
            MapWinGIS.Extents ex = new MapWinGIS.Extents();
            ex.SetBounds(ubicacion.X - (PlugData.MapWin.View.Extents.xMax - PlugData.MapWin.View.Extents.xMin) / 2, ubicacion.Y - (PlugData.MapWin.View.Extents.yMax - PlugData.MapWin.View.Extents.yMin) / 2, 0, ubicacion.X + (PlugData.MapWin.View.Extents.xMax - PlugData.MapWin.View.Extents.xMin) / 2, ubicacion.Y + (PlugData.MapWin.View.Extents.yMax - PlugData.MapWin.View.Extents.yMin) / 2, 0);
            PlugData.MapWin.View.Extents = ex;

            // dibujar
            PlugData.MapWin.View.Draw.DrawCircle(ubicacion.X, ubicacion.Y, 10, Color.Red, true);

            PlugData.MapWin.View.Draw.ClearDrawing(PlugData.DrGrifos.Value);
            PlugData.DrGrifos = PlugData.MapWin.View.Draw.NewDrawing(MapWinGIS.tkDrawReferenceList.dlSpatiallyReferencedList);
            foreach (PostgresDataAccess.Grifo g in grifos)
            {
                if (g.Utilizado)
                {
                    PlugData.MapWin.View.Draw.DrawCircle(g.Ubicacion.X, g.Ubicacion.Y, 10, Color.DarkOrange, true);
                }
                else
                {
                    PlugData.MapWin.View.Draw.DrawCircle(g.Ubicacion.X, g.Ubicacion.Y, 10, Color.Yellow, true);
                }
            }
        }
예제 #8
0
        }// End FastPolygonsIntersect

        #region --------------------------- POINTS WITHIN EXTENTS ----------------------------------

        /// <summary>
        /// Finds a list of point indecies from a MapWinGIS.Shape that are within the extents specified
        /// </summary>
        /// <param name="Shape">Any shapefile with points.</param>
        /// <param name="Envelope">A MapWinGIS.Extents object representing the area of interrest</param>
        /// <returns>Returns a list of integer point indecies in Shape that are within Envelope</returns>
        public static List <int> PointsWithinEnvelope(MapWinGIS.Shape Shape, MapWinGIS.Extents Envelope)
        {
            Envelope Rect;

            Rect = new Envelope(Envelope);
            return(PointsWithinRect(Shape, Rect));
        }
예제 #9
0
        /// <summary>
        /// Draws selected bounds on map
        /// </summary>
        /// <param name="ext">Bounding box to search CS</param>
        public void DrawSelectedBounds(MapWinGIS.Extents ext)
        {
            this.RemoveLayer(m_handleBounds);

            MapWinGIS.Shapefile sf = new MapWinGIS.Shapefile();
            if (sf.CreateNew("", MapWinGIS.ShpfileType.SHP_POLYGON))
            {
                MapWinGIS.Shape shp = new MapWinGIS.Shape();
                shp.Create(MapWinGIS.ShpfileType.SHP_POLYGON);
                this.InsertPart(shp, ext.xMin, ext.xMax, ext.yMin, ext.yMax);

                int index = 0;
                sf.EditInsertShape(shp, ref index);

                m_handleBounds = this.AddLayer(sf, true);

                MapWinGIS.ShapeDrawingOptions options = sf.DefaultDrawingOptions;
                MapWinGIS.Utils ut = new MapWinGIS.Utils();
                options.FillColor        = ut.ColorByName(MapWinGIS.tkMapColor.Orange);
                options.LineColor        = ut.ColorByName(MapWinGIS.tkMapColor.Orange);
                options.LineWidth        = 3;
                options.LineStipple      = MapWinGIS.tkDashStyle.dsDash;
                options.FillTransparency = 100;
            }
            else
            {
                System.Diagnostics.Debug.Print("Failed to create in-memory shapefile");
            }
        }
예제 #10
0
 /// <summary>
 /// Creates a new instance of Extents from double values in the MapWinGIS.Extents object
 /// </summary>
 /// <param name="Bounds">A MapWinGIS.Extents object to define a rectangle</param>
 public Extents(MapWinGIS.Extents Bounds)
 {
     xMin = Bounds.xMin;
     xMax = Bounds.xMax;
     yMin = Bounds.yMin;
     yMax = Bounds.yMax;
 }
예제 #11
0
        // calculates extent (bounding box) of shapefile layer -
        // the extent is slightly larger than original shapefile extent:
        // values are rounded to whole pixels
        private MapWinGIS.Extents calcShapefileExtent(MapWinGIS.Shapefile shp)
        {
            double cellSize = m_DefaultCellSize;

            Utils.string2double(txtCellSize.Text, out cellSize);

            MapWinGIS.Extents ext = shp.Extents;

            double xMin = ((int)(ext.xMin / cellSize)) * cellSize;
            double yMin = ((int)(ext.yMin / cellSize)) * cellSize;

            int nCols = ((int)((ext.xMax - ext.xMin) / cellSize)) + 1;

            lblNumberCols.Text = nCols.ToString();

            int nRows = ((int)((ext.yMax - ext.yMin) / cellSize)) + 1;

            lblNumberRows.Text = nRows.ToString();

            double xMax = xMin + nCols * cellSize;
            double yMax = yMin + nRows * cellSize;

            MapWinGIS.Extents newExtents = new MapWinGIS.Extents();
            newExtents.SetBounds(xMin, yMin, 0, xMax, yMax, 0);
            return(newExtents);
        }
예제 #12
0
        /// <summary>
        /// 显示对话框,选择投影,提示是否将投影应用于项目,并返回用户选择的投影
        ///  在状态栏和项目属性中可以调用
        /// </summary>
        public MapWinGIS.GeoProjection SetProjectProjectionByDialog()
        {
            MapWinGIS.GeoProjection proj = this.GetProjectionFromUser(); //从对话框中获取到选择的投影

            bool needsReloading = false;

            if (proj != null)
            {
                //检测是否需要重新加载项目,来重新设置投影
                if (Program.frmMain.Layers.NumLayers > 0 && !Program.frmMain.Project.GeoProjection.IsEmpty)
                {
                    MapWinGIS.Extents ext = Program.frmMain.MapMain.MaxExtents;
                    if (!proj.IsSameExt[Program.frmMain.Project.GeoProjection, ext]) //检测当前投影和项目投影是否一致
                    {
                        //不一致,则重投
                        if (MessageBox.Show("此操作需要重新加载项目,来在图层上重新投影。继续?", Program.frmMain.ApplicationInfo.ApplicationName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            needsReloading = true;
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }

                //设置新的投影
                MapWinGIS.GeoProjection projOld = Program.frmMain.Project.GeoProjection;
                Program.frmMain.Project.GeoProjection = proj;

                if (needsReloading) //需要重新加载,则保存加载
                {
                    // 保存原来的
                    if (this.Modified)
                    {
                        Program.frmMain.DoSave();
                    }

                    // 取消保存
                    if (this.Modified)
                    {
                        Program.frmMain.Project.GeoProjection = projOld;
                        return(null);
                    }
                    else
                    {
                        // 确保用户在重新加载时看见必要的对话框
                        Program.frmMain.ApplicationInfo.ShowLoadingReport         = true;
                        Program.frmMain.ApplicationInfo.NeverShowProjectionDialog = false;
                        Program.appInfo.ProjectReloading = true;

                        return(proj);
                    }
                }
            }

            return(null);
        }
예제 #13
0
 public static void ZoomToLocation(PointD p1, PointD p2)
 {
     MapWin.View.LockMap();
     MapWin.View.ZoomToMaxExtents();
     MapWinGIS.Extents ex = MapWin.View.Extents;
     ex.SetBounds(p1.X, p1.Y, 0, p2.X, p2.Y, 0);
     MapWin.View.Extents = ex;
     MapWin.View.UnlockMap();
 }
예제 #14
0
        private void SelectExtents(MapWinGIS.Extents ext)
        {
            object[] Shapes = new object[m_Map.NumLayers];
            if (m_CurrentLayer == -1 || m_CurrentLayer >= m_Map.NumLayers)
            {
                for (int lyr = 0; lyr < m_Map.NumLayers; lyr++)
                {
                    object ob = m_Map.get_GetObject(lyr);
                    if (ob.GetType() != typeof(MapWinGIS.Shapefile))
                    {
                        return;
                    }
                    MapWinGIS.Shapefile sf = ob as MapWinGIS.Shapefile;
                    sf.SelectShapes(ext, 0, MapWinGIS.SelectMode.INTERSECTION, ref Shapes[m_CurrentLayer]);
                }
            }
            else
            {
                object ob = m_Map.get_GetObject(m_CurrentLayer);
                if (ob.GetType() != typeof(MapWinGIS.Shapefile))
                {
                    return;
                }
                MapWinGIS.Shapefile sf = ob as MapWinGIS.Shapefile;
                sf.SelectShapes(ext, 0, MapWinGIS.SelectMode.INTERSECTION, ref Shapes[m_CurrentLayer]);
            }

            m_Map.SuspendLayout();
            // If shift is down then we append to the selection
            if (m_ShiftPressed == false)
            {
                // Clear the selection first

                ClearSelectedShapes();
            }

            //Append selected shapes
            for (int lyr = 0; lyr < m_Map.NumLayers; lyr++)
            {
                int[] myShapes = Shapes[lyr] as int[];
                for (int shp = 0; shp <= myShapes.GetUpperBound(0); shp++)
                {
                    if (m_SelectedShapes[lyr].Contains(myShapes[shp]))
                    {
                        continue;
                    }
                    m_SelectedShapes[lyr].Add(myShapes[shp]);
                }
            }

            for (int lyr = 0; lyr < m_SelectedShapes.GetUpperBound(0); lyr++)
            {
                Highlight_Layer(lyr);
            }

            m_Map.ResumeLayout();
        }
예제 #15
0
        // updates values in the "grid extent" box
        // (min. X, min. Y, max. X, max. Y, columns, rows)
        /// <summary>
        /// updates values in the "grid extent" box
        /// (min. X, min. Y, max. X, max. Y, num.columns, num.rows.
        /// The extent values are rounded to nearest whole cellsize
        /// </summary>
        /// <param name="extents">the extents of new grid</param>
        /// <param name="roundValues">set to TRUE if the xMin and yMin values
        /// should be rounded to whole cell size.</param>
        private void UpdateExtentBox(MapWinGIS.Extents extents)
        {
            txtMinX.Text = extents.xMin.ToString();
            txtMinY.Text = extents.yMin.ToString();
            txtMaxX.Text = extents.xMax.ToString();
            txtMaxY.Text = extents.yMax.ToString();

            UpdateExtentBox();
        }
예제 #16
0
 /// <summary>
 /// Creates a new instance of Envelope from double values in the MapWinGIS.Extents object
 /// </summary>
 /// <param name="Bounds">A MapWinGIS.Extents object to define a rectangle</param>
 public Envelope(MapWinGIS.Extents Bounds)
 {
     xMin = Bounds.xMin;
     xMax = Bounds.xMax;
     yMin = Bounds.yMin;
     yMax = Bounds.yMax;
     zMin = Bounds.zMin;
     zMax = Bounds.zMax;
 }
예제 #17
0
 /// <summary>
 /// Checks each value in the point to see if they are the same
 /// </summary>
 /// <param name="Ext">The Extents to compare with this point</param>
 /// <returns>Boolean, true if the points are the same</returns>
 public bool AreIdenticalTo(MapWinGIS.Extents Ext)
 {
     if ((xMin == Ext.xMin) && (yMin == Ext.yMin) && (zMin == Ext.zMin) &&
         (xMax == Ext.xMax) && (yMax == Ext.yMax) && (zMax == Ext.zMax))
     {
         return(true);
     }
     return(false);
 }
예제 #18
0
        public BookmarkAddNew(string newName, MapWinGIS.Extents newExtents)
        {
            InitializeComponent();
            if (newExtents != null)
            {
                m_BookmarkExtents = new MapWinGIS.Extents();
                m_BookmarkExtents.SetBounds(newExtents.xMin, newExtents.yMin, newExtents.zMin, newExtents.xMax, newExtents.yMax, newExtents.zMax);
            }

            m_BookmarkName = newName;
        }
예제 #19
0
        //private static void Serializar(PointD punto)
        //{
        //    FileStream f = new FileStream(Ruta + @"\ubicacion.txt", FileMode.Create);
        //    BinaryFormatter b = new BinaryFormatter();
        //    b.Serialize(f, punto);
        //    f.Close();
        //}

        public static void ZoomToPointsPaint(PointD[] points, string[] labels)
        {
            if (points.Length == 1)
            {
                ZoomToPoint(points[0]);
                MapWin.View.Draw.ClearDrawing(DrCarros.Value);
                DrCarros = MapWin.View.Draw.NewDrawing(MapWinGIS.tkDrawReferenceList.dlSpatiallyReferencedList);
                LMapa.ClearLabels();
                // pintar punto
                MapWin.View.Draw.DrawCircle(points[0].X, points[0].Y, 10, System.Drawing.Color.Red, true);
                LMapa.AddLabel(labels[0], Color.Black, points[0].X, points[0].Y - 10, MapWinGIS.tkHJustification.hjCenter);
            }
            else
            {
                double minx = double.MaxValue;
                double maxx = double.MinValue;
                double miny = double.MaxValue;
                double maxy = double.MinValue;

                MapWin.View.Draw.ClearDrawing(DrCarros.Value);
                LMapa.ClearLabels();
                DrCarros = MapWin.View.Draw.NewDrawing(MapWinGIS.tkDrawReferenceList.dlSpatiallyReferencedList);

                for (int i = 0; i < points.Length; i++)
                {
                    // calcular extent seleccionando los 4 puntos límite
                    PointD p = points[i];
                    if (p.X < minx)
                    {
                        minx = p.X;
                    }
                    if (p.X > maxx)
                    {
                        maxx = p.X;
                    }
                    if (p.Y < miny)
                    {
                        miny = p.Y;
                    }
                    if (p.Y > maxy)
                    {
                        maxy = p.Y;
                    }

                    // pintar punto
                    MapWin.View.Draw.DrawCircle(p.X, p.Y, 10, System.Drawing.Color.Red, true);
                    LMapa.AddLabel(labels[i], Color.Black, p.X, p.Y - 10, MapWinGIS.tkHJustification.hjCenter);
                }
                // establecer extent
                MapWinGIS.Extents ex = MapWin.View.Extents;
                ex.SetBounds(minx - 100, miny - 100, 0, maxx + 100, maxy + 100, 0);
                MapWin.View.Extents = ex;
            }
        }
예제 #20
0
 public static void ZoomToPointPaint(PointD p, int radio)
 {
     MapWin.View.LockMap();
     MapWin.View.ZoomToMaxExtents();
     MapWinGIS.Extents ex = MapWin.View.Extents;
     ex.SetBounds(p.X - radio, p.Y - radio, 0, p.X + radio, p.Y + radio, 0);
     MapWin.View.Extents = ex;
     MapWin.View.Draw.ClearDrawing(DrDireccion.Value);
     DrDireccion = MapWin.View.Draw.NewDrawing(MapWinGIS.tkDrawReferenceList.dlSpatiallyReferencedList);
     MapWin.View.Draw.DrawCircle(p.X, p.Y, 10, System.Drawing.Color.Red, true);
     MapWin.View.UnlockMap();
 }
예제 #21
0
 /// <summary>
 /// 在指定的范围返回一个MapWinGIS.Image类型的对象的视角
 /// </summary>
 /// <param name="boundBox">The area that you wish to take the picture of.  Uses projected map units.</param>
 public MapWinGIS.Image GetScreenPicture(MapWinGIS.Extents boundBox)
 {
     try
     {
         return((MapWinGIS.Image)Program.frmMain.MapMain.SnapShot(boundBox));
     }
     catch (Exception ex)
     {
         Program.ShowError(ex);
         return(null);
     }
 }
 private bool PointInView(Point p)
 {
     MapWinGIS.Extents e = m_globals.MapWin.View.Extents;
     if (p.x < e.xMax && p.x > e.xMin && p.y < e.yMax && p.y > e.yMin)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #23
0
 /// <summary>
 /// Zooms map to the bounds of coordinate system
 /// </summary>
 public void ZoomToCoordinateSystem()
 {
     MapWinGIS.Shapefile sf = this.get_Shapefile(m_handleCS);
     if (sf != null)
     {
         MapWinGIS.Extents sfExt = sf.Extents;
         double            dx    = sfExt.xMax - sfExt.xMin;
         double            dy    = sfExt.xMax - sfExt.xMin;
         MapWinGIS.Extents ext   = new MapWinGIS.Extents();
         ext.SetBounds(sfExt.xMin - dx / 4.0, sfExt.yMin - dy / 4.0, 0.0, sfExt.xMax + dx / 4.0, sfExt.yMax + dy / 4.0, 0.0);
         this.Extents = ext;
     }
 }
예제 #24
0
            public DVInfo(MapWinGIS.Extents Exts, bool UseExts, int LayerHandle)
            {
                this.m_Extents = Exts;
                this.m_Scale   = Program.frmMain.ExtentsToScale(m_Extents);
                m_handle       = LayerHandle;

                if (Program.frmMain.MapMain.ShapeDrawingMethod != MapWinGIS.tkShapeDrawingMethod.dmNewSymbology)
                {
                    m_UseExtents = UseExts;
                }
                else
                {
                    m_UseExtents = false;
                }
            }
예제 #25
0
        // This is the full blown select for a drag style extent
        void m_Map_SelectBoxFinal(object sender, AxMapWinGIS._DMapEvents_SelectBoxFinalEvent e)
        {
            // First get the projected coordinates
            double top    = 0;
            double left   = 0;
            double bottom = 0;
            double right  = 0;

            m_Map.PixelToProj(e.left, e.top, ref left, ref top);
            m_Map.PixelToProj(e.right, e.bottom, ref right, ref bottom);

            MapWinGIS.Extents ext = new MapWinGIS.Extents();
            ext.SetBounds(left, bottom, 0, right, top, 0);
            SelectExtents(ext);
        }
예제 #26
0
        void m_Map_MouseUpEvent(object sender, AxMapWinGIS._DMapEvents_MouseUpEvent e)
        {
            // Select using an approximation of 5 pixels about e
            double top    = 0;
            double left   = 0;
            double bottom = 0;
            double right  = 0;

            m_Map.PixelToProj(e.x - 5, e.y - 5, ref left, ref top);
            m_Map.PixelToProj(e.x + 5, e.y + 5, ref right, ref bottom);

            MapWinGIS.Extents ext = new MapWinGIS.Extents();
            ext.SetBounds(left, bottom, 0, right, top, 0);
            SelectExtents(ext);
        }
예제 #27
0
        public static void ZoomToPoint(PointD p)
        {
            double dx, dy;

            MapWin.View.LockMap();
            MapWin.View.ZoomToMaxExtents();
            MapWinGIS.Extents ex = MapWin.View.Extents;
            dx  = ex.xMax - ex.xMin;
            dx *= MapWin.View.ExtentPad;
            dy  = ex.yMax - ex.yMin;
            dy *= MapWin.View.ExtentPad;
            //ex.SetBounds(p.X - (dx / 2), p.Y - (dy / 2), 0, p.X + (dx / 2), p.Y + (dy / 2), 0);
            ex.SetBounds(p.X - 200, p.Y - 200, 0, p.X + 200, p.Y + 200, 0);

            MapWin.View.Extents = ex;
            MapWin.View.UnlockMap();
        }
예제 #28
0
        private static void CreateGridFromExtents(MapWinGIS.Extents InExtents, double CellSize, String Projection, double NoDataValue, string OutGridPath, out MapWinGIS.Grid OutGrid)
        {
            double height = Math.Abs(InExtents.yMax - InExtents.yMin);
            double width  = Math.Abs(InExtents.xMax - InExtents.xMin);

            OutGrid = new MapWinGIS.Grid();
            MapWinGIS.GridHeader hdr = new MapWinGIS.GridHeader();

            hdr.dX          = CellSize;
            hdr.dY          = CellSize;
            hdr.NodataValue = NoDataValue;
            hdr.NumberRows  = int.Parse(Math.Ceiling(height / CellSize).ToString());
            hdr.NumberCols  = int.Parse(Math.Ceiling(width / CellSize).ToString());
            hdr.Projection  = Projection;
            hdr.XllCenter   = InExtents.xMin + 0.5 * CellSize;
            hdr.YllCenter   = InExtents.yMin + 0.5 * CellSize;

            OutGrid.CreateNew(OutGridPath, hdr, MapWinGIS.GridDataType.DoubleDataType, NoDataValue, true, MapWinGIS.GridFileType.UseExtension, null);
        }
예제 #29
0
        /// <summary>
        /// 在给定的点下,查询所有的活动的shapefile层
        /// Queries all of the active shapefile layers for any within the specified tolerance of the given point.
        /// </summary>
        /// <param name="ProjX">要查询的相对于地图的x点坐标</param>
        /// <param name="ProjY">要查询的相对于地图的y点坐标</param>
        /// <param name="Tolerance">在所查询点坐标周围,允许的距离</param>
        /// <returns>Returns an <c>IdentifiedLayers</c> object containing query results.</returns>
        public MapWinGIS.Interfaces.IdentifiedLayers Identify(double ProjX, double ProjY, double Tolerance)
        {
            MainProgram.IdentifiedShapes identifyshpfile;
            MainProgram.IdentifiedLayers ilyr = new MainProgram.IdentifiedLayers();
            int i, j;

            MapWinGIS.Shapefile shpfile;
            object o, res = null;

            MapWinGIS.Extents box;
            int count = Program.frmMain.MapMain.NumLayers;

            for (i = 0; i < count; i++) //遍历每一个图层
            {
                int lyrHandle = Program.frmMain.MapMain.get_LayerHandle(i);
                if (Program.frmMain.MapMain.get_LayerVisible(lyrHandle)) //是可见的图层
                {
                    o = Program.frmMain.MapMain.get_GetObject(lyrHandle);
                    if (o is MapWinGIS.Shapefile) //获取是shapefile类型的图层
                    {
                        shpfile = (MapWinGIS.Shapefile)o;
                        o       = null;
                        box     = new MapWinGIS.Extents();
                        box.SetBounds(ProjX, ProjY, 0, ProjX, ProjY, 0);
                        if (shpfile.SelectShapes(box, Tolerance, MapWinGIS.SelectMode.INTERSECTION, ref res)) //搜索该点,结果存在res中
                        {
                            identifyshpfile = new MainProgram.IdentifiedShapes();
                            Array arr;
                            arr = (Array)res; //得到在该点下的所有shape的索引集合
                            for (j = 0; j < arr.Length; j++)
                            {
                                identifyshpfile.Add((int)(arr.GetValue(j)));
                            }
                            ilyr.Add(identifyshpfile, lyrHandle);
                        }
                    }
                }
            }
            return(ilyr);
        }
예제 #30
0
 /// <summary>
 /// Determines if two MapWinGIS.Shape objects have rectangular extents that touch or intersect
 /// </summary>
 /// <param name="Shape1">A MapWinGIS.Shape to test the rectangular extents of</param>
 /// <param name="Shape2">A Second MapWinGIS.Shape to test the rectangular extents of</param>
 /// <returns>Boolean, true if the extents overlap or touch.</returns>
 public static bool EnvelopeIntersect(MapWinGIS.Shape Shape1, MapWinGIS.Shape Shape2)
 {
     MapWinGIS.Extents ext1 = Shape1.Extents;
     MapWinGIS.Extents ext2 = Shape2.Extents;
     if (ext1.xMin >= ext2.xMax)
     {
         return(false);
     }
     if (ext1.yMin >= ext2.yMax)
     {
         return(false);
     }
     if (ext2.xMin >= ext1.xMax)
     {
         return(false);
     }
     if (ext2.yMin >= ext1.yMax)
     {
         return(false);
     }
     return(true);
 }
예제 #31
0
        /// <summary>
        /// Zooms map to the bounds of coordinate system
        /// </summary>
        /// <param name="cs"></param>
        public void ZoomToCoordinateSystem(Territory cs)
        {
            if (cs == null)
            {
                return;
            }

            MapWinGIS.Extents ext = new MapWinGIS.Extents();

            double dx = cs.Right - cs.Left;
            double dy = cs.Top - cs.Bottom;

            if (dx >= 0)
            {
                ext.SetBounds(cs.Left - dx / 4.0, cs.Bottom - dy / 4.0, 0.0, cs.Right + dx / 4.0, cs.Top + dy / 4.0, 0.0);
            }
            else
            {
                dx = 360.0;
                ext.SetBounds(-180.0 - dx / 4.0, cs.Bottom - dy / 4.0, 0.0, 180.0 + dx / 4.0, cs.Top + dy / 4.0, 0.0);
            }
            this.Extents = ext;
        }