- 相關(guān)推薦
Java實(shí)現(xiàn)點(diǎn)在線添加的方法
Java如何實(shí)現(xiàn)點(diǎn)在線添加,下面YJBYS小編為大家整理了相關(guān)資料,希望對(duì)你有所幫助。內(nèi)容如下:
public void addPoint(MapEvent event){
AGSLocalMapResource res = (AGSLocalMapResource)this.webContext.getResources()。get(“ags0”);
try{
// 建立一個(gè)工作空間工廠對(duì)象,并設(shè)置它的參數(shù)信息。
SdeWorkspaceFactory sdewf = (SdeWorkspaceFactory)res.getServerContext()。createObject(SdeWorkspaceFactory.getClsid());
PropertySet pset = (PropertySet)res.getServerContext()。createObject(PropertySet.getClsid());
pset.setProperty(“SERVER”, “gxk”);// 服務(wù)器名稱
pset.setProperty(“INSTANCE”, “5151”);// 實(shí)例名
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ù)的原因是:由于在開始編輯時(shí)新打開了一個(gè)工作空間,該工作空間并不是瀏覽器中看到地圖所在的工作空間。
【Java實(shí)現(xiàn)點(diǎn)在線添加的方法】相關(guān)文章:
Java動(dòng)態(tài)代理實(shí)現(xiàn)AOP的方法07-22
java實(shí)現(xiàn)web服務(wù)器的方法10-14
實(shí)現(xiàn)鼠標(biāo)畫圖的Java程序06-22
Java如何實(shí)現(xiàn)簡(jiǎn)單的whois查詢09-21
Java byte[]轉(zhuǎn)int如何實(shí)現(xiàn)05-24
Java語(yǔ)言的特點(diǎn)和實(shí)現(xiàn)機(jī)制10-01
使用JavaScript實(shí)現(xiàn)Java的List功能10-26
Java枚舉的常用方法10-05