点线面缓冲分析
//缓冲分析主要是生产缓冲图形,再用缓冲图形执行空间查询。 //把需要缓冲的对象放在sesssion中,这样可以对同一个缓冲对象执行多个条件的缓冲分析 ESRI.ArcGIS.ADF.Web.Geometry.Geometry geo = (ESRI.ArcGIS.ADF.Web.Geometry.Geometry)(map1.Page.Session["BufferAnalyesGeometry"]); double dis; if (!Double.TryParse(eventArg,out dis)) { dis = 0.0; } //获取mxd配置文件中的图层属性信息 ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality qfunc = (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality)map1.GetFunctionality("地图名"); //获取对象缓冲图形 if (qfunc.Resource is ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal) { ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal ags_mr = (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal)qfunc.Resource; ESRI.ArcGIS.Server.IServerContext sc = ags_mr.ServerContextInfo.ServerContext; ESRI.ArcGIS.ADF.ArcGISServer.MapDescription mapdescription; mapdescription = qfunc.MapDescription; //定义Com对象的点 ESRI.ArcGIS.Geometry.IGeometry igeo=null; //点缓冲自定义方法,线、面缓冲用AO控件方法 ESRI.ArcGIS.ADF.Web.Geometry.Polygon nplygon; if (geo is ESRI.ArcGIS.ADF.Web.Geometry.Point) { //生成点的缓冲图形 ESRI.ArcGIS.ADF.Web.Geometry.Point cp=(ESRI.ArcGIS.ADF.Web.Geometry.Point)geo; common.Utils uts = new common.Utils(); ESRI.ArcGIS.ADF.Web.Geometry.PointCollection pc = uts.getMapPointBuffer(cp.X, cp.Y,dis, 1); ESRI.ArcGIS.ADF.Web.Geometry.Ring r1= new ESRI.ArcGIS.ADF.Web.Geometry.Ring(); r1.Points = pc; ESRI.ArcGIS.ADF.Web.Geometry.RingCollection rc = new ESRI.ArcGIS.ADF.Web.Geometry.RingCollection(); rc.Add(r1); nplygon = new ESRI.ArcGIS.ADF.Web.Geometry.Polygon(); nplygon.Rings = rc; } else { if (geo is ESRI.ArcGIS.ADF.Web.Geometry.Polyline) { //线转换 ESRI.ArcGIS.ADF.Web.Geometry.Polyline pl = (ESRI.ArcGIS.ADF.Web.Geometry.Polyline)geo; ESRI.ArcGIS.Geometry.IPointCollection com_polyline_pointcollection = (ESRI.ArcGIS.Geometry.IPointCollection)sc.CreateObject("esriGeometry.Polyline"); object Missing = Type.Missing; foreach (ESRI.ArcGIS.ADF.Web.Geometry.Path new_adf_path in pl.Paths) { ESRI.ArcGIS.Geometry.IPointCollection com_pointcollection = (ESRI.ArcGIS.Geometry.IPointCollection)sc.CreateObject("esriGeometry.Path"); foreach (ESRI.ArcGIS.ADF.Web.Geometry.Point new_adf_point in new_adf_path.Points) { ESRI.ArcGIS.Geometry.IPoint com_point = (ESRI.ArcGIS.Geometry.IPoint) ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToIGeometry(new_adf_point, sc); com_pointcollection.AddPoint(com_point, ref Missing, ref Missing); } com_polyline_pointcollection.AddPointCollection(com_pointcollection); } ESRI.ArcGIS.Geometry.IPolyline projpoly = (ESRI.ArcGIS.Geometry.IPolyline)com_polyline_pointcollection; igeo = projpoly; } else { igeo = (ESRI.ArcGIS.Geometry.IGeometry)ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToIGeometry(geo, sc); } //利用AO中缓冲区分析 ESRI.ArcGIS.Geometry.ITopologicalOperator topop = (ESRI.ArcGIS.Geometry.ITopologicalOperator)igeo; ESRI.ArcGIS.Geometry.IPolygon bufferPolygon; bufferPolygon = (ESRI.ArcGIS.Geometry.IPolygon)topop.Buffer(dis); // // 定义valueobject的点 ESRI.ArcGIS.ADF.ArcGISServer.PolygonN buffer_polyn; // 进行comobject到valueobject之间的转换 buffer_polyn = (ESRI.ArcGIS.ADF.ArcGISServer.PolygonN) ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ComObjectToValueObject (bufferPolygon, sc, typeof(ESRI.ArcGIS.ADF.ArcGISServer.PolygonN)); nplygon = (ESRI.ArcGIS.ADF.Web.Geometry.Polygon)ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToAdfPolygon(buffer_polyn); } //在Buffer图层中显示结果 ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality mapFunct = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality)map1.GetFunctionality(mapBufferName); ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource gResource = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource)mapFunct.Resource; gResource.Graphics.Tables.Clear(); ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer glayer = new ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer(); gResource.Graphics.Tables.Add(glayer); ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement ge1 = new ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(nplygon,System.Drawing.Color.SeaGreen); ge1.Symbol.Transparency = 70.0; glayer.Add(ge1); //刷新地图 map1.RefreshResource(gResource.Name); string[] lids = m_queryString["Layers"].Split(",".ToCharArray()); //执行空间查询 。。。。 。。。 |