点线面缓冲分析(转自esri中国社区)
點線面緩沖分析
| //緩沖分析主要是生產緩沖圖形,再用緩沖圖形執行空間查詢。 //把需要緩沖的對象放在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()); ? ?? ?? ?? ?? ?? ?? ?? ?? ? //執行空間查詢 ? ?? ?? ?? ?? ?? ?? ?? ?? ? 。。。。 。。。 |
轉載于:https://www.cnblogs.com/weihongli/archive/2011/08/10/2133358.html
總結
以上是生活随笔為你收集整理的点线面缓冲分析(转自esri中国社区)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 方法的返回值类型是object_Java
- 下一篇: 电脑维修:电脑故障通用处理思路,你有必要