• arcgis 矩形查询


    default.aspx页面添加矩形查询控件:

    <esri:Tool ClientAction="DragRectangle" DefaultImage="Images/MapTool/rectquery1.gif"
                        HoverImage="Images/MapTool/rectquery2.gif" SelectedImage="Images/MapTool/rectquery2.gif"
                        Name="Rectangle" ServerActionAssembly="App_Code" ServerActionClass="IdentifyRectangle"
                        ToolTip="矩形查询" />

    在app_code里面添加IdentifyRectangle类,代码如下:

    //添加的引用
    using ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools;
    using ESRI.ArcGIS.ADF.Web.UI.WebControls;
    using ESRI.ArcGIS.ADF.Web.Geometry;

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

        public void ServerAction(ToolEventArgs args)
        {
            Map map = args.Control as Map;
            RectangleEventArgs rectargs = (RectangleEventArgs)args;
            System.Drawing.Rectangle myrect = rectargs.ScreenExtent;
            Point minPoint = Point.ToMapPoint(myrect.Left, myrect.Bottom, map.Extent, (int)map.Width.Value, (int)map.Height.Value);
            Point maxPoint = Point.ToMapPoint(myrect.Right, myrect.Top, map.Extent, (int)map.Width.Value, (int)map.Height.Value);
            Envelope mapPoly = new Envelope(minPoint, maxPoint);

            IdentifyHelper.IdentifyRectangle(map, mapPoly);
        }

    在IdentifyHelper类中添加IdentifyRectangle方法:

    /// <summary>
        /// 矩形查询
        /// </summary>
        /// <param name="map"></param>
        /// <param name="mapPoly"></param>
        public static void IdentifyRectangle(Map map, ESRI.ArcGIS.ADF.Web.Geometry.Geometry mapPoly)
        {
            IGISFunctionality gisFunc = map.GetFunctionality("Portland");
            if (gisFunc == null)
                return;
            IGISResource gisresource = gisFunc.Resource;
            bool supportquery = gisresource.SupportsFunctionality(typeof(IQueryFunctionality));
            if (!supportquery)
                return;
            //得到查询功能
            IQueryFunctionality qfunc;
            qfunc = gisresource.CreateFunctionality(typeof(IQueryFunctionality), null) as IQueryFunctionality;
            //得到可查询图层的数组和名称
            string[] lIDs, lNames;
            qfunc.GetQueryableLayers(null, out lIDs, out lNames);

            ESRI.ArcGIS.ADF.Web.SpatialFilter spatialfilter = new ESRI.ArcGIS.ADF.Web.SpatialFilter();
            spatialfilter.ReturnADFGeometries = false;
            spatialfilter.MaxRecords = 1000;//查询最多返回1000条数据
            spatialfilter.Geometry = mapPoly;

            System.Data.DataSet ds = new DataSet();
            for (int i = 0; i < lIDs.Length; i++)
            {
                System.Data.DataTable dt = qfunc.Query(null, lIDs[i], spatialfilter);
                if (dt == null)
                    return;
                dt.TableName = lNames[i];
                ds.Tables.Add(dt);
            }
            DataTableCollection dtc = ds.Tables;

       //显示结果
            ShowIdentifyResult(map, dtc);

           //高亮显示
            HighLighShow(map, dtc);
        }

    上面ShowIdentifyResult方法和HighLighShow方法在点查询里有喔!

  • 相关阅读:
    oracle锁---原理篇
    SML + NL + HJ
    Oracle中varchar,varchar2,nvarchar,nvarchar2的区别
    oracle 一致读原理
    commit 流程
    IMPDP NETWORK_LINK参数
    WINDOWS访问虚拟机RedHat搭配的Apache2服务器
    初识malloc函数
    好吧,又失眠
    休息一天
  • 原文地址:https://www.cnblogs.com/lff255356/p/2737674.html
Copyright © 2020-2023  润新知