- 相關推薦
Java如何實現(xiàn)點的在線添加
public void addPoint(MapEvent event){
AGSLocalMapResource res = (AGSLocalMapResource)this.webContext.getResources().get("ags0");
try{
// 建立一個工作空間工廠對象,并設置它的參數(shù)信息。
SdeWorkspaceFactory sdewf = (SdeWorkspaceFactory)res.getServerContext().createObject(SdeWorkspaceFactory.getClsid());
PropertySet pset = (PropertySet)res.getServerContext().createObject(PropertySet.getClsid());
pset.setProperty("SERVER", "gxk");// 服務器名稱
pset.setProperty("INSTANCE", "5151");// 實例名
pset.setProperty("USER", "sa"); // SDE數(shù)據(jù)表空間的用戶名
pset.setProperty("PASSWORD", "sa");// 密碼
pset.setProperty("VERSION", "DBO.gxk");// SDE數(shù)據(jù)的版本
Workspace iws =(Workspace) sdewf.open(pset, 0);
WebPoint screenPoint = (WebPoint)event.getWebGeometry();
WebMap mapctrl = event.getWebContext().getWebMap();
WebPoint mappnt =WebPoint.toMapPoint(screenPoint, mapctrl.getCurrentExtent(), (int)mapctrl.getWidth(), (int)mapctrl.getHeight());
Geometry soapgeo=AGSUtil.toAGSGeometry(mappnt);
String soapString = com.esri.adf.web.ags.util.AGSUtil.serializeStub(soapgeo);
soapString = soapString.replaceAll("xsi:type=\"soapenc:Array\"", "");
IPoint mypoint = (IPoint)AGSUtil.deserializeArcObject(soapString, res.getServerContext());
IWorkspaceEdit wse = (IWorkspaceEdit)iws;
wse.startEditing(false);
wse.startEditOperation();
IFeatureClass featureclass = iws.openFeatureClass("sde.DBO.Respt");
IFeature feature = featureclass.createFeature();
feature.setShapeByRef((IGeometry)mypoint);
feature.setValue(feature.getFields().findField("NAME"), "kkk");
feature.store();
wse.stopEditOperation();
wse.stopEditing(true);
this.webContext.refresh();
}catch(Exception e){
e.printStackTrace();
}
}
刷新地圖后不能顯示新加入的數(shù)據(jù)的原因是:由于在開始編輯時新打開了一個工作空間,該工作空間并不是瀏覽器中看到地圖所在的工作空間。
【Java如何實現(xiàn)點的在線添加】相關文章:
使用JavaScript實現(xiàn)Java的List功能08-09
word如何添加標題樣式07-30
PPT如何添加超鏈接10-16
如何給Word添加背景音樂09-16
如何為Word添加小助手09-20
ppt中如何添加超鏈接10-01
如何實現(xiàn)員工的有效激勵07-23
如何給Word文檔中的圖片添加邊框07-30
有關Excel表格中如何添加橫線05-01