zoukankan      html  css  js  c++  java
  • ArcGIS自定义图形选择工具

    最近在研究ArcGIS Server方面的知识,看了好几本书,查找了好些资料(说实话在网上找关于GIS方面的资料真的很少),今天花了一个上午的时间把各种图形选择工具都研究了一遍,把我的研究结果拿出来跟大家分享分享。

    1、单击选择:进行单击选择的时候,需要把屏幕上的点对象转换成ADF中的几何对象(ADF中的点)

    2、矩形选择:矩形选择就是将屏幕中的矩形转换成ADF中的矩形对象,也就是把屏幕矩形的点转换成ADF中的点,然后在把点组装成ADF中的矩形

    3、折线选择:

    4、多边形选择

    6、圆圈选择

        //一、单击选择工具
        //进行单击选择的时候,需要将屏幕上的点对象转换成ADF上的几何对象,转换程序如下
        private ESRI.ArcGIS.ADF.Web.Geometry.Geometry ConvertToADFGeometry(PointEventArgs args, Map adfmap)
        {
            //1、获得屏幕上单击的点对象
            System.Drawing.Point screenPoint = args.ScreenPoint;
            //2、将屏幕点对象转换成ADF中的几何对象
            ESRI.ArcGIS.ADF.Web.Geometry.Point adfPoint =ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screenPoint.X,screenPoint.Y,adfmap.GetTransformationParams(ESRI.ArcGIS.ADF.Web.Geometry.TransformationDirection.ToMap));
              //ESRI.ArcGIS.ADF.Web.Geometry.Point adfPoint =ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screenPoint.X,screenPoint.Y,adfmap.Extent,adfmap.Width,adfmap.Height);
            //返回ADF几何对象
            return adfPoint;
        }
    
        //二、矩形选择工具
        //矩形选择也需要把屏幕上的矩形对象转换成ADF几何对象(矩形对象),也就是把屏幕矩形的点转换成ADF的点,然后再构成ADF的矩形,转换方式如下
        // 把屏幕上行的点转换成ADF矩形对象
        private ESRI.ArcGIS.ADF.Web.Geometry.Geometry ConvertToADFGeometry(RectangleEventArgs args,Map adfmap)
        {
            //1、获得屏幕矩形对象
            System.Drawing.Rectangle screeRectangle = args.ScreenExtent;
            //2、将屏幕矩形对象的左上坐标和左下坐标转换成ADF中的几何图形的坐标
            ESRI.ArcGIS.ADF.Web.Geometry.Point point1 = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screeRectangle.Left, screeRectangle.Bottom, adfmap.GetTransformationParams(ESRI.ArcGIS.ADF.Web.Geometry.TransformationDirection.ToMap));
            //3、将屏幕矩形对象的右下坐标和右上坐标转换成ADF中的几何图像的坐标
            ESRI.ArcGIS.ADF.Web.Geometry.Point point2 = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screeRectangle.Right, screeRectangle.Top, adfmap.GetTransformationParams(ESRI.ArcGIS.ADF.Web.Geometry.TransformationDirection.ToMap));
            //4、将转换后的ADF几何点坐标组装成ADF中的矩形图形
            ESRI.ArcGIS.ADF.Web.Geometry.Envelope envelope =new  ESRI.ArcGIS.ADF.Web.Geometry.Envelope(point1, point2);
            //5、返回ADF中的矩形
            return envelope;
        }
    
        //折线选择工具
        //折线的转换方式和矩形的类似
        private ESRI.ArcGIS.ADF.Web.Geometry.Geometry ConvertToADFGeometry(PolylineEventArgs args, Map adfmap)
        {
            //ESRI.ArcGIS.ADF.Web.Geometry.Point adfpoint = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(args.BeginPoint.X,args.BeginPoint.Y,adfmap.GetTransformationParams(ESRI.ArcGIS.ADF.Web.Geometry.TransformationDirection.ToMap));
            ESRI.ArcGIS.ADF.Web.Geometry.Path path = new ESRI.ArcGIS.ADF.Web.Geometry.Path();
            for (int i = 0; i < args.Vectors.Length;i++ )
            {
                ESRI.ArcGIS.ADF.Web.Geometry.Point adfPoint = Point.ToMapPoint(args.Vectors[i].X, args.Vectors[i].Y, adfmap.GetTransformationParams(TransformationDirection.ToMap));
                path.Points.Add(adfPoint);
                        }
            Polyline polyline = new Polyline();
            polyline.Paths.Add(path);
            return polyline;
        }
        //多边形选择工具
        //多边形的转换方式与折线的相似,转换方式如下
        //把屏幕上的点转换成ADF中的多边形
        private Geometry ConvertToADFGetmetry(PolygonEventArgs args,Map adfmap)
        {
            //ESRI.ArcGIS.ADF.Web.Geometry.Point adfpoint = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(args.BeginPoint.X,args.BeginPoint.Y,adfmap.GetTransformationParams(ESRI.ArcGIS.ADF.Web.Geometry.TransformationDirection.ToMap));
            Ring ring = new Ring();
            for (int i = 0; i < args.Vectors.Length;i++ )
            {
                Point adfPoint = Point.ToMapPoint(args.Vectors[i].X, args.Vectors[i].Y, adfmap.GetTransformationParams(TransformationDirection.ToMap));
                ring.Points.Add(adfPoint);
             
    
            }
            Polygon polygon = new Polygon();
            polygon.Rings.Add(ring);
            return polygon;
        }
    
        //圆圈选择工具
        //圆的转换与上面提到的转换方式有些区别,因为ADF中么有圆的对象,所以只能把圆转换成多边形对象。在把圆转换成多边形对象的时候,根据圆心、半径,并在一定的角度取点后,把这些点转换成ADF中的点,再把ADF中的点转换成多边形,转换方式如下
        private Geometry ConvertToADFGetmetry(CircleEventArgs args,Map adfmap)
        {
            PointCollection pc = new PointCollection();
            double degress;
            double red = args.Radius;
            for (int i = 0; i < 360; i++)
            {
                degress = i * (Math.PI / 180);
                double x = args.CenterPoint.X + Math.Cos(degress) * red;
                double y = args.CenterPoint.Y + Math.Sin(degress) * red;
                ESRI.ArcGIS.ADF.Web.Geometry.Point point = Point.ToMapPoint((int)Math.Round(x), (int)Math.Round(y), adfmap.GetTransformationParams(TransformationDirection.ToMap));
                pc.Add(point);
            }
            ESRI.ArcGIS.ADF.Web.Geometry.Ring ring = new ESRI.ArcGIS.ADF.Web.Geometry.Ring();
            ring.Points = pc;
            Polygon polygon = new Polygon();
            polygon.Rings.Add(ring);
            return polygon;
        }
    
  • 相关阅读:
    java -inally转
    11.Android-Xml读写
    10.Android-SharedPreferences使用
    9.Android-读写SD卡案例
    8.Android-简单的登录案例编写
    7.Android-压力测试、单元测试、日志猫使用
    python 向mysql中存储图片以及读取图片
    Android Studio 4.0+ 中新的 UI 层次结构调试工具
    微信小程序又放大招,代码包的大小限制由1M扩到2M
    硅谷禁书全集(5册)- 带完整封面目录,全面优化版
  • 原文地址:https://www.cnblogs.com/yshuaiw/p/3070704.html
Copyright © 2011-2022 走看看