zoukankan      html  css  js  c++  java
  • arcgis 多边形查询

    在default.aspx页面添加多边形控件:

    <esri:Tool ClientAction="Polygon" Name="PolygonIdentify" DefaultImage="Images/MapTool/polyquery1.gif"
                        HoverImage="Images/MapTool/polyquery2.gif" SelectedImage="Images/MapTool/polyquery2.gif"
                        ServerActionAssembly="App_Code" ServerActionClass="IdentifyPolygon" Text="PolygonIdentify"
                        ToolTip="多边形查询" />

    在app_code里面添加IdentifyPolygon类,实现代码如下:

    //添加的命名空间
    using ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools;
    using ESRI.ArcGIS.ADF.Web.UI.WebControls;
    using ESRI.ArcGIS.ADF.Web.Geometry;

    /// <summary>
    ///IdentifyPolygon 实现多边形查询
    /// </summary>
    public class IdentifyPolygon : IMapServerToolAction
    {
        public IdentifyPolygon()
        {
            //
            //TODO: 在此处添加构造函数逻辑
            //
        }

        void IMapServerToolAction.ServerAction(ToolEventArgs args)
        {
            Map map = args.Control as Map;
            PolygonEventArgs polyArgs = (PolygonEventArgs)args;
            Polygon mapPoly = IdentifyHelper.GetMapPolygon(map, polyArgs);
            IdentifyHelper.IdentifyRectangle(map, mapPoly);
        }

    在IdentifyHelper类中添加GetMapPolygon方法:

    /// <summary>
        /// 多边形查询
        /// </summary>
        /// <param name="map"></param>
        /// <param name="polyArgs"></param>
        /// <returns></returns>
        public static ESRI.ArcGIS.ADF.Web.Geometry.Polygon GetMapPolygon(Map map, PolygonEventArgs polyArgs)
        {
            System.Drawing.Point[] screenpoly = polyArgs.Vectors;
            PointCollection pc = new ESRI.ArcGIS.ADF.Web.Geometry.PointCollection();
            foreach (System.Drawing.Point dpnt in screenpoly)
            {
                pc.Add(ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(dpnt, map.Extent, (int)map.Width.Value, (int)map.Height.Value));
            }
            ESRI.ArcGIS.ADF.Web.Geometry.Ring ring = new ESRI.ArcGIS.ADF.Web.Geometry.Ring();
            ring.Points = pc;
            RingCollection rings = new RingCollection();
            rings.Add(ring);
            ESRI.ArcGIS.ADF.Web.Geometry.Polygon mapPoly = new ESRI.ArcGIS.ADF.Web.Geometry.Polygon();
            mapPoly.Rings = rings;
            return mapPoly;
        }

    IdentifyRectangle方法在矩形查询里已有了喔!

  • 相关阅读:
    [转]字符串相似度算法(编辑距离算法 Levenshtein Distance)
    [转]Earth Mover's Distance (EMD)
    [转]相似度计算常用方法综述
    小和问题和逆序对问题
    递归的理解
    验证方法是否正确——对数器
    CSS的几个核心概念(复盘大纲~)
    CSS3过渡
    CSS经典布局
    CSS3边框和圆角
  • 原文地址:https://www.cnblogs.com/lff255356/p/2737681.html
Copyright © 2011-2022 走看看