예제 #1
0
 public void Update(GISExtent _extent, Rectangle _rectangle)
 {
     CurrentMapExtent = _extent;
     MapWindowsSize   = _rectangle;
     MapMinX          = CurrentMapExtent.getMinX();
     MapMinY          = CurrentMapExtent.getMinY();
     WinW             = MapWindowsSize.Width;
     WinH             = MapWindowsSize.Height;
     MapW             = CurrentMapExtent.getWidth();
     MapH             = CurrentMapExtent.getHeight();
     ScaleX           = MapW / WinW;
     ScaleY           = MapH / WinH;
 }
예제 #2
0
        private void GISPanel_MouseUp(object sender, MouseEventArgs e)
        {
            if (document.IsEmpty())
            {
                return;
            }
            if (MouseOnMap == false)
            {
                return;
            }
            MouseOnMap = false;
            switch (MouseCommand)
            {
            case MOUSECOMMAND.Select:
                //如果CTRL没被按住,就清空选择集 按住CTRL键表示选择多个 即向选择集中新增空间对象
                if (Control.ModifierKeys != Keys.Control)
                {
                    document.ClearSelection();
                }
                //初始化选择结果
                SelectResult sr = SelectResult.UnknownType;
                if (e.X == MouseStartX && e.Y == MouseStartY)
                {
                    //点选
                    GISVertex v = view.ToMapVertex(e.Location);
                    sr = document.Select(v, view);
                }
                else
                {
                    //框选
                    GISExtent extent = view.Rect2Extent(e.X, MouseStartX, e.Y, MouseStartY);
                    sr = document.Select(extent);
                }
                if (sr == SelectResult.OK || Control.ModifierKeys != Keys.Control)
                {
                    UpdateMap();
                    UpdateAttributeWindow();
                }
                break;

            case MOUSECOMMAND.Zoomin:
                if (e.X == MouseStartX && e.Y == MouseStartY)
                {
                    //单点放大
                    GISVertex MouseLocation = view.ToMapVertex(e.Location);
                    GISExtent E1            = view.getRealExtent();
                    double    newwidth      = E1.getWidth() * GISConst.ZoominFactor;
                    double    newheight     = E1.getHeight() * GISConst.ZoominFactor;
                    double    newminx       = MouseLocation.x - (MouseLocation.x - E1.getMinX()) * GISConst.ZoominFactor;
                    double    newminy       = MouseLocation.y - (MouseLocation.y - E1.getMinY()) * GISConst.ZoominFactor;
                    view.UpdateExtent(new GISExtent(newminx, newminx + newwidth, newminy, newminy + newheight));
                }
                else
                {
                    //拉框放大
                    view.UpdateExtent(view.Rect2Extent(e.X, MouseStartX, e.Y, MouseStartY));
                }
                UpdateMap();
                break;

            case MOUSECOMMAND.Zoomout:
                if (e.X == MouseStartX && e.Y == MouseStartY)
                {
                    //单点缩小
                    GISExtent e1            = view.getRealExtent();
                    GISVertex mouselocation = view.ToMapVertex(e.Location);
                    double    newwidth      = e1.getWidth() / GISConst.ZoomoutFactor;
                    double    newheight     = e1.getHeight() / GISConst.ZoomoutFactor;
                    double    newminx       = mouselocation.x - (mouselocation.x - e1.getMinX()) / GISConst.ZoomoutFactor;
                    double    newminy       = mouselocation.y - (mouselocation.y - e1.getMinY()) / GISConst.ZoomoutFactor;
                    view.UpdateExtent(new GISExtent(newminx, newminx + newwidth, newminy, newminy + newheight));
                }
                else
                {
                    //拉框缩小
                    GISExtent e3        = view.Rect2Extent(e.X, MouseStartX, e.Y, MouseStartY);
                    GISExtent e1        = view.getRealExtent();
                    double    newwidth  = e1.getWidth() * e1.getWidth() / e3.getWidth();
                    double    newheight = e1.getHeight() * e1.getHeight() / e3.getHeight();
                    double    newminx   = e3.getMinX() - (e3.getMinX() - e1.getMinX()) * newwidth / e1.getWidth();
                    double    newminy   = e3.getMinY() - (e3.getMinY() - e1.getMinY()) * newheight / e1.getHeight();
                    view.UpdateExtent(new GISExtent(newminx, newminx + newwidth, newminy, newminy + newheight));
                }
                UpdateMap();
                break;

            case MOUSECOMMAND.Pan:
                if (e.X != MouseStartX && e.Y != MouseStartY)
                {
                    GISExtent e1        = view.getRealExtent();
                    GISVertex m1        = view.ToMapVertex(new Point(MouseStartX, MouseStartY));
                    GISVertex m2        = view.ToMapVertex(e.Location);
                    double    newwidth  = e1.getWidth();
                    double    newheight = e1.getHeight();
                    double    newminx   = e1.getMinX() - (m2.x - m1.x);
                    double    newminy   = e1.getMinY() - (m2.y - m1.y);
                    view.UpdateExtent(new GISExtent(newminx, newminx + newwidth, newminy, newminy + newheight));
                    UpdateMap();
                }
                break;
            }
        }
예제 #3
0
 //判断两个空间对象是否相交 排除所有不相交情况就得到相交
 public bool IntersectOrNot(GISExtent extent)
 {
     return(!(getMaxX() < extent.getMinX()) || getMinX() > extent.getMaxX() ||
            getMaxY() < extent.getMinY() || getMinY() > extent.getMaxY());
 }