- public ? class ?PointEdit?{ ??
- ???????? private ?WebContext?webContext; ??
- ???????? public ? void ?AddPoint?(MapEvent?event){ ??
- ???????????????? try ?{ ??
- ???????????????????????? //得到地图事件所对应的地图对象 ??
- ????????????????????????WebMap?webmap=webContext.getWebMap(); ??
- ????????????????????????WebPoint?webpoint=(WebPoint)?????????event.getWebGeometry().toMapGeometry(webmap);??????????????????????? ??
- ????????????????????????AGSLocalMapResource?mapResource?=?(AGSLocalMapResource)?MapResourceClass.getMapResource(webContext,? 1 ); ??
- ????????????????????????IServerContext?context?=?mapResource.getServerContext(); ??
- ????????????????????????MapServer?mapServer?=?mapResource.getLocalMapServer(); ??
- ???????????????????????? //IMap?maps=?mapServer.getMap(""); ??
- ???????????????????????? //ILayer?firstLayer?=?maps.getLayer(Otid); ??
- ???????????????????????? //得到图层的空间编辑对象 ??
- ????????????????????????IMap?maps=?mapServer.getMap( "" ); ??
- ????????????????????????ILayer?layer=maps.getLayer( 0 ); ??
- ????????????????????????IFeatureLayer?fLayer?=?(IFeatureLayer)?layer; ??
- ????????????????????????IFeatureClass?fc?=?fLayer.getFeatureClass(); ??
- ????????????????????????IDataset?ds1= new ?IDatasetProxy(fc); ??
- ????????????????????????IWorkspace?pWorkSpace?=?ds1.getWorkspace(); ??
- ????????????????????????IWorkspaceEdit?pWorkspaceEdit= new ?IWorkspaceEditProxy(pWorkSpace); ??
- ???????????????????????? //开始编辑 ??
- ????????????????????????pWorkspaceEdit.startEditing( true ); ??
- ????????????????????????pWorkspaceEdit.startEditOperation(); ??
- ???????????????????????? //创建新的地图对象 ??
- ????????????????????????IFeature?pFeature=fc.createFeature(); ??
- ???????????????????????? //将web地图对象转成地图对象 ??
- ????????????????????????Point?p=(Point)context.createObject( "esriGeometry.Point" ); ??
- ????????????????????????IPoint?pt=(IPoint)context.createObject( "esriGeometry.Point" ); ??
- ????????????????????????pt.setX(webpoint.getX()); ??
- ????????????????????????pt.setY(webpoint.getY()); ??
- ????????????????????????pt.setM( 0 ); ??
- ????????????????????????pt.setZ( 0 ); ??
- ????????????????????????p=(Point)pt; ??
- ???????????????????????? //地图对象赋值 ??
- ????????????????????????pFeature.setShapeByRef(p); ??
- ???????????????????????? //字段赋值 ??
- ????????????????????????pFeature.setValue(fc.findField( "code" ),? 1 ); ??
- ???????????????????????? //保存对象 ??
- ????????????????????????pFeature.store(); ??
- ???????????????????????? //停止编辑 ??
- ????????????????????????pWorkspaceEdit.stopEditOperation(); ??
- ????????????????????????pWorkspaceEdit.stopEditing( true ); ??
- ??
- ???????????????????????? //刷新地图 ??
- ????????????????????????mapServer.refreshServerObjects(); ??
- ????????????????????????webContext.refresh(); ??
- ??????????????????????? ??
- ????????????????}? catch ?(Exception?gise)?{ ??
- ????????????????????????System.out.print( "添加点" ?+?gise.toString()?+? "\n" ); ??
- ????????????????????????gise.printStackTrace(); ??
- ????????????????}??????????????????????? ??
- ????????} ??
- } ??
- 这是添加点的代码 ??
- using?System; ??
- using?System.Data; ??
- using?System.Configuration; ??
- using?System.Web; ??
- using?System.Web.Security; ??
- using?System.Web.UI; ??
- using?System.Web.UI.WebControls; ??
- using?System.Web.UI.WebControls.WebParts; ??
- using?System.Web.UI.HtmlControls; ??
- ??
- using?ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools; ??
- using?ESRI.ArcGIS.ADF.Web.UI.WebControls; ??
- using?ESRI.ArcGIS.ADF.ArcGISServer; ??
- using?ESRI.ArcGIS.Server; ??
- using?ESRI.ArcGIS.Carto; ??
- using?ESRI.ArcGIS.Geometry; ??
- using?ESRI.ArcGIS.esriSystem; ??
- using?ESRI.ArcGIS.Display; ??
- using?System.Collections; ??
- using?ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer; ??
- using?ESRI.ArcGIS.Geodatabase; ??
- ///?<summary> ??
- ///?AddPointFeature?的摘要说明 ??
- ///?</summary> ??
- public ? class ?AddPointFeature?:?IMapServerToolAction ??
- { ??
- public ?AddPointFeature() ??
- { ??
- ?? // ??
- ?? //?TODO:?在此处添加构造函数逻辑 ??
- ?? // ??
- } ??
- ????#region?IMapServerToolAction?成员 ??
- ???? void ?IMapServerToolAction.ServerAction(ToolEventArgs?args) ??
- ????{ ??
- ???????? //Step1:?取到地图点击画的那个点 ??
- ????????ESRI.ArcGIS.ADF.Web.UI.WebControls.Map?mapCtrl; ??
- ????????mapCtrl?=?(ESRI.ArcGIS.ADF.Web.UI.WebControls.Map)args.Control; ??
- ????????PointEventArgs?pea?=?(PointEventArgs)args; ??
- ????????System.Drawing.Point?screen_point?=?pea.ScreenPoint; ??
- ????????MapFunctionality?mapFunc?=?(MapFunctionality)mapCtrl.GetFunctionality( 0 ); ??
- ????????MapResourceLocal?mapResLocal?=?mapFunc.Resource?as?MapResourceLocal;???????? ??
- ????????IServerContext?pSOC; ??
- ????????IMapServer?pMapServer; ??
- ????????IMap?pMap; ??
- ???????? ??
- ????????pSOC?=?mapResLocal.ServerContextInfo.ServerContext; ??
- ????????pMapServer?=?pSOC.ServerObject?as?IMapServer; ??
- ????????IMapServerObjects?pMapServerObjs?=?pMapServer?as?IMapServerObjects; ??
- ????????pMap?=?pMapServerObjs.get_Map(pMapServer.DefaultMapName); ??
- ????????ESRI.ArcGIS.ADF.ArcGISServer.MapDescription?mapDesp?=?mapFunc.MapDescription; ??
- ????????ESRI.ArcGIS.ADF.Web.Geometry.Point?adf_map_point?=?ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screen_point,?mapCtrl.Extent,?mapFunc.DisplaySettings.ImageDescriptor.Width,?mapFunc.DisplaySettings.ImageDescriptor.Height); ??
- ????????PointN?ags_map_point?=?ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromAdfPoint(adf_map_point); ??
- ??
- ???????? //Step2:插入点到Shp文件中去。要打开WS ??
- ???????? //第一个图层是点,第二个图层是线,第三个图层是面。这里就不判断,主要在于功能的实现 ??
- ????????ILayer?pLayer?=?pMap.get_Layer( 0 ); ??
- ????????IFeatureLayer?pFeatureLyr?=?pLayer?as?IFeatureLayer; ??
- ????????IFeatureClass?pFeatCls?=?pFeatureLyr.FeatureClass; ??
- ????????IDataset?pDataset?=?pFeatCls?as?IDataset; ??
- ????????IWorkspace?pWS?=?pDataset.Workspace; ??
- ????????IWorkspaceEdit?pWorkspaceEdit?=?pWS?as?IWorkspaceEdit; ??
- ????????pWorkspaceEdit.StartEditing( false ); ??
- ????????pWorkspaceEdit.StartEditOperation(); ??
- ????????IFeatureBuffer?pFeatureBuffer; ??
- ????????IFeatureCursor?pFeatureCuror; ??
- ????????IFeature?pFeature; ??
- ????????IPoint?pPoint; ??
- ????????pFeatureBuffer?=?pFeatCls.CreateFeatureBuffer(); ??
- ????????pFeatureCuror?=?pFeatCls.Insert( true ); ??
- ????????pFeature?=?pFeatureBuffer?as?IFeature; ??
- ????????pPoint?=(IPoint)?pSOC.CreateObject( "esriGeometry.Point" ); ??
- ????????pPoint.X?=?ags_map_point.X; ??
- ????????pPoint.Y?=?ags_map_point.Y; ??
- ????????IGeometry?pPointGeo?=?pPoint?as?IGeometry; ??
- ????????pFeature.Shape?=?pPointGeo; ??
- ????????pFeatureCuror.InsertFeature(pFeatureBuffer); ??
- ???????? ??
- ????????pWorkspaceEdit.StopEditOperation(); ??
- ????????pWorkspaceEdit.StopEditing( true );???????? ??
- ????????mapCtrl.Refresh();????? ??
- ????} ??
- ????#endregion ??
- } ??
- ?? ??
- 添加线的代码 ??
- ??
- ??
- using?System; ??
- using?System.Data; ??
- using?System.Configuration; ??
- using?System.Web; ??
- using?System.Web.Security; ??
- using?System.Web.UI; ??
- using?System.Web.UI.WebControls; ??
- using?System.Web.UI.WebControls.WebParts; ??
- using?System.Web.UI.HtmlControls; ??
- ??
- using?ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools; ??
- using?ESRI.ArcGIS.ADF.Web.UI.WebControls; ??
- using?ESRI.ArcGIS.ADF.ArcGISServer; ??
- using?ESRI.ArcGIS.Server; ??
- using?ESRI.ArcGIS.Carto; ??
- using?ESRI.ArcGIS.Geometry; ??
- using?ESRI.ArcGIS.esriSystem; ??
- using?ESRI.ArcGIS.Display; ??
- using?System.Collections; ??
- using?ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer; ??
- using?ESRI.ArcGIS.Geodatabase; ??
- ///?<summary> ??
- ///?AddPolylineFeature?的摘要说明 ??
- ///?</summary> ??
- public ? class ?AddPolylineFeature?:?IMapServerToolAction ??
- { ??
- public ?AddPolylineFeature() ??
- { ??
- ?? // ??
- ?? //?TODO:?在此处添加构造函数逻辑 ??
- ?? // ??
- } ??
- ????#region?IMapServerToolAction?成员 ??
- ???? public ? void ?ServerAction(ToolEventArgs?args) ??
- ????{ ??
- ???????? //Step1:根据客户端定义的动作,将屏幕坐标点转换成地图坐标点 ??
- ???????? //并初始化一些常用的参数 ??
- ????????ESRI.ArcGIS.ADF.Web.UI.WebControls.Map?mapCtrl; ??
- ????????mapCtrl?=?(ESRI.ArcGIS.ADF.Web.UI.WebControls.Map)args.Control; ??
- ????????PolylineEventArgs?peal?=?(PolylineEventArgs)args; ??
- ????????System.Drawing.Point[]?screen_points?=?peal.Vectors; ??
- ????????MapFunctionality?mapFunc?=?(MapFunctionality)mapCtrl.GetFunctionality( 0 ); ??
- ????????MapResourceLocal?mapResLocal?=?mapFunc.Resource?as?MapResourceLocal; ??
- ????????ESRI.ArcGIS.ADF.ArcGISServer.MapDescription?mapDesc; ??
- ????????mapDesc?=?mapFunc.MapDescription; ??
- ????????IServerContext?pSOC; ??
- ????????IMapServer?pMapServer; ??
- ????????IMap?pMap; ??
- ????????pSOC?=?mapResLocal.ServerContextInfo.ServerContext; ??
- ????????pMapServer?=?pSOC.ServerObject?as?IMapServer; ??
- ????????IMapServerObjects?pMapServerObjs?=?pMapServer?as?IMapServerObjects; ??
- ????????pMap?=?pMapServerObjs.get_Map(pMapServer.DefaultMapName); ??
- ??
- ????????IPointCollection?pPointColl; ??
- ????????pPointColl?=?(IPointCollection)pSOC.CreateObject( "esriGeometry.Polyline" ); ??
- ???????? for ?( int ?i?=? 0 ;?i?<?screen_points.Length;?i++) ??
- ????????{ ??
- ????????????IPoint?pPoint; ??
- ????????????ESRI.ArcGIS.ADF.Web.Geometry.Point?mappnt?=?ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screen_points,?mapCtrl.Extent,?( int )mapCtrl.Width.Value,?( int )mapCtrl.Height.Value); ??
- ????????????pPoint?=?(IPoint)pSOC.CreateObject( "esriGeometry.Point" ); ??
- ????????????pPoint.X?=?mappnt.X; ??
- ????????????pPoint.Y?=?mappnt.Y; ??
- ????????????object?missingVal?=?System.Reflection.Missing.Value; ??
- ????????????pPointColl.AddPoint(pPoint,?ref?missingVal,?ref?missingVal); ??
- ????????} ??
- ????????IGeometry?pPolylineGeo?=?pPointColl?as?IGeometry; ??
- ??
- ???????? //Step2:插入点到Shp文件中去。要打开WS ??
- ???????? //第一个图层是点(0),第二个图层是线(1),第三个图层是面(2)。这里就不判断,主要在于功能的实现 ??
- ????????ILayer?pLayer?=?pMap.get_Layer( 1 ); ??
- ????????IFeatureLayer?pFeatureLyr?=?pLayer?as?IFeatureLayer; ??
- ????????IFeatureClass?pFeatCls?=?pFeatureLyr.FeatureClass; ??
- ????????IDataset?pDataset?=?pFeatCls?as?IDataset; ??
- ????????IWorkspace?pWS?=?pDataset.Workspace; ??
- ????????IWorkspaceEdit?pWorkspaceEdit?=?pWS?as?IWorkspaceEdit; ??
- ????????pWorkspaceEdit.StartEditing( false ); ??
- ????????pWorkspaceEdit.StartEditOperation(); ??
- ????????IFeatureBuffer?pFeatureBuffer; ??
- ????????IFeatureCursor?pFeatureCuror; ??
- ????????IFeature?pFeature; ??
- ????????pFeatureBuffer?=?pFeatCls.CreateFeatureBuffer(); ??
- ????????pFeatureCuror?=?pFeatCls.Insert( true ); ??
- ????????pFeature?=?pFeatureBuffer?as?IFeature; ??
- ????????pFeature.Shape?=?pPolylineGeo; ??
- ????????pFeatureCuror.InsertFeature(pFeatureBuffer); ??
- ????????pWorkspaceEdit.StopEditOperation(); ??
- ????????pWorkspaceEdit.StopEditing( true ); ??
- ????????mapCtrl.Refresh();????? ??
- ????} ??
- ????#endregion ??
- } ??
- 编辑面的代码 ??
- ??
- ??
- using?System; ??
- using?System.Data; ??
- using?System.Configuration; ??
- using?System.Web; ??
- using?System.Web.Security; ??
- using?System.Web.UI; ??
- using?System.Web.UI.WebControls; ??
- using?System.Web.UI.WebControls.WebParts; ??
- using?System.Web.UI.HtmlControls; ??
- ??
- using?ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools; ??
- using?ESRI.ArcGIS.ADF.Web.UI.WebControls; ??
- using?ESRI.ArcGIS.ADF.ArcGISServer; ??
- using?ESRI.ArcGIS.Server; ??
- using?ESRI.ArcGIS.Carto; ??
- using?ESRI.ArcGIS.Geometry; ??
- using?ESRI.ArcGIS.esriSystem; ??
- using?ESRI.ArcGIS.Display; ??
- using?System.Collections; ??
- using?ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer; ??
- using?ESRI.ArcGIS.Geodatabase; ??
- ///?<summary> ??
- ///?AddPolygonFeature?的摘要说明 ??
- ///?</summary> ??
- public ? class ?AddPolygonFeature?:?IMapServerToolAction ??
- { ??
- public ?AddPolygonFeature() ??
- { ??
- ?? // ??
- ?? //?TODO:?在此处添加构造函数逻辑 ??
- ?? // ??
- } ??
- ????#region?IMapServerToolAction?成员 ??
- ???? public ? void ?ServerAction(ToolEventArgs?args) ??
- ????{ ??
- ???????? //Step1:根据客户端定义的动作,将屏幕坐标点转换成地图坐标点 ??
- ???????? //并初始化一些常用的参数 ??
- ????????ESRI.ArcGIS.ADF.Web.UI.WebControls.Map?mapCtrl; ??
- ????????mapCtrl?=?(ESRI.ArcGIS.ADF.Web.UI.WebControls.Map)args.Control; ??
- ????????PolygonEventArgs?peag?=?(PolygonEventArgs)args; ??
- ????????System.Drawing.Point[]?screen_points?=?peag.Vectors; ??
- ????????MapFunctionality?mapFunc?=?(MapFunctionality)mapCtrl.GetFunctionality( 0 ); ??
- ????????MapResourceLocal?mapResLocal?=?mapFunc.Resource?as?MapResourceLocal; ??
- ????????ESRI.ArcGIS.ADF.ArcGISServer.MapDescription?mapDesc; ??
- ????????mapDesc?=?mapFunc.MapDescription; ??
- ????????IServerContext?pSOC; ??
- ????????IMapServer?pMapServer; ??
- ????????IMap?pMap; ??
- ????????pSOC?=?mapResLocal.ServerContextInfo.ServerContext; ??
- ????????pMapServer?=?pSOC.ServerObject?as?IMapServer; ??
- ????????IMapServerObjects?pMapServerObjs?=?pMapServer?as?IMapServerObjects; ??
- ????????pMap?=?pMapServerObjs.get_Map(pMapServer.DefaultMapName); ??
- ??
- ??
- ????????IPointCollection?pPointColl; ??
- ????????pPointColl?=?(IPointCollection)pSOC.CreateObject( "esriGeometry.Polygon" ); ??
- ???????? for ?( int ?i?=? 0 ;?i?<?screen_points.Length;?i++) ??
- ????????{ ??
- ????????????IPoint?pPoint; ??
- ????????????ESRI.ArcGIS.ADF.Web.Geometry.Point?mappnt?=?ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screen_points,?mapCtrl.Extent,?( int )mapCtrl.Width.Value,?( int )mapCtrl.Height.Value); ??
- ????????????pPoint?=?(IPoint)pSOC.CreateObject( "esriGeometry.Point" ); ??
- ????????????pPoint.X?=?mappnt.X; ??
- ????????????pPoint.Y?=?mappnt.Y; ??
- ????????????object?missingVal?=?System.Reflection.Missing.Value; ??
- ????????????pPointColl.AddPoint(pPoint,?ref?missingVal,?ref?missingVal); ??
- ????????} ??
- ????????IGeometry?pPolylineGeo?=?pPointColl?as?IGeometry; ??
- ??
- ???????? //Step2:插入点到Shp文件中去。要打开WS ??
- ???????? //第一个图层是点(0),第二个图层是线(1),第三个图层是面(2)。这里就不判断,主要在于功能的实现 ??
- ????????ILayer?pLayer?=?pMap.get_Layer( 2 ); ??
- ????????IFeatureLayer?pFeatureLyr?=?pLayer?as?IFeatureLayer; ??
- ????????IFeatureClass?pFeatCls?=?pFeatureLyr.FeatureClass; ??
- ????????IDataset?pDataset?=?pFeatCls?as?IDataset; ??
- ????????IWorkspace?pWS?=?pDataset.Workspace; ??
- ????????IWorkspaceEdit?pWorkspaceEdit?=?pWS?as?IWorkspaceEdit; ??
- ????????pWorkspaceEdit.StartEditing( false ); ??
- ????????pWorkspaceEdit.StartEditOperation(); ??
- ????????IFeatureBuffer?pFeatureBuffer; ??
- ????????IFeatureCursor?pFeatureCuror; ??
- ????????IFeature?pFeature; ??
- ????????pFeatureBuffer?=?pFeatCls.CreateFeatureBuffer(); ??
- ????????pFeatureCuror?=?pFeatCls.Insert( true ); ??
- ????????pFeature?=?pFeatureBuffer?as?IFeature; ??
- ????????pFeature.Shape?=?pPolylineGeo; ??
- ????????pFeatureCuror.InsertFeature(pFeatureBuffer); ??
- ????????pWorkspaceEdit.StopEditOperation(); ??
- ????????pWorkspaceEdit.StopEditing( true ); ??
- ????????mapCtrl.Refresh();????? ??
- ????} ??
- ????#endregion ??
-
}?
详细解决方案
基于ArcGIS Server对ShapeFile资料的编辑功能实现
热度:391 发布时间:2012-07-25 09:43:05.0
相关解决方案
- myeclipse联接sql server 2008看不到用户表
- Server Tomcat v7.0 Server不能起步
- 在哪找的SQL Server 2005数据库驱动文件?为什么sql server2005安装盘上面没有找到
- The server encountered an internal error () that prevented it from fulfilling th解决方案
- JSP运行异常 STRUTS + SQL SERVER 2005
- jsp连接sql server 2005时出现的异常
- jsp连接sql server 2005数据库是异常!
- 大家帮帮忙呀The server encountered an internal error () that prevented it解决方法
- ASP上Set GetSession("conn")=server.CreateObject("adodb.connection")
- Server Apache Tomcat v6.0.35 at localhost failed to start
- JDBC 连接sql server 2005老是失败怎么处理?恳请高手帮忙。
- SOS-(奇怪现象)服务器暂不可用500 internal server error,该怎么解决
- tomcat没法运行Could not publish to the server. Error while expanding
- sql server 设置非空默认值之后,hibernate添加出现异常
- WEBstruts The server encountered an internal error () that prevented it fr解决思路
- jsp连接sql server 2005错误
- 可以安装在win7系统的sql server
- 出现异常:cvs [server aborted]:"passwd" requires write access to the repository
- exchange server 2000提供全部用户邮件到达的java api吗
- jdbc 直连sql server 2000 连不下
- Error 500-Internal Server Error 如何解决
- JAVA连接SQL SERVER 2000数据库,该如何解决
- Server returned HTTP response code: 403 for URL如何解决
- IM聊天系统的有关问题,用Tigase Server 如何实现挤线功能
- com.microsoft.sqlserver.jdbc.SQLServerException: 用户 'sa' 登录失败。该用户与可托 SQL Server
- Error 500--Internal Server Error
- Error 500-Internal Server Error
- jbuilder2006 连接 sql server 2000新有关问题
- java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]l??????? hstmt
- eclipse中不能筑tomcat server