sde是Spatial Database Engine简写,中文全称:空间数据库引擎。
SDE是一种客户/服务器软件,可使空间数据在工业标准的数据库管理系统中存储、管理和快速查询检索。把GIS数据放在RDBMS中,但是一般的RDBMS都没有提供GIS的数据类型(如点、线、多边形、以及这些feature之间的拓扑关系和投影坐标等相关信息),RDBMS只提供了少量的数据类型支持:int,float,double,Blob,Long,char等,一般都是数字,字符串和二进制数据几种。并且RDBMS不仅没有提取对GIS数据类型的存储,也没有提供对这些基础类型的操作(如:判断包含关系,相邻、相交、求差、距离、最短路径等)JAVA对sde操作,首先需要下载sde支持的jar包。jpe92_sdk.jar和jsde92_sdk.jar两个包,这两个包可以从安装的目录下找到。下面是java获的sde的链接代码:
[java] view plaincopyprint?01./**02. *连接sde服务03. * @return04. */ 05. public SeConnectiongetConnection () { 06. SeConnection conn = null ; 07. try { 08. conn = new SeConnection(SDE_SERVER_IP, SDE_PROT,SDE_DATEBASE_SID, SDE_USERNAME, SDE_PASSWORD); 09. } catch(SeException e) { 10. return null; 11. } 12. return conn; 13. }
对sde数据进行添加,点线面的新增
[java] view plaincopyprint?01./**02. * 添加资源信息点到sde中03. * @param pointBean 坐标点 POJO04. * @param tbName 图层名称05. * @param String typeName 所画的类型 1 点 2 线 3 面06. * @return Long sde的id07. * @throws Exception08. */ 09. publicLong addPointObject(PointBean pointBean, List columnList, String tableName,String typeName) throws Exception { 10. SeLayer insertLayer = null; 11. SeConnection conn = null; 12. Long intsertRowID =null; 13. SeInsert insert = null; 14. try { 15. conn = this.getConnection(); 16. insertLayer= new SeLayer( conn, tableName, "SHAPE"); 17. if (insertLayer== null) { 18. throw new Exception("找不到空间表:" + tableName); 19. } 20. conn.startTransaction(); 21. int arrayLength = columnList.size() + 1 ; 22. String[] cols = new String[arrayLength]; 23. cols[0] = "SHAPE"; 24. for (int i = 0 ;i sde查询接口实现 [java] view plaincopyprint?01./**02. * 查询sde03. *@param productId 产品id04. * @throws SeException05. */ www.cdtarena.com06. public SeQuerysearchSde (Long productId, String tableName) throws SeException { 07. SeConnection conn = getConnection(); 08. SeLayerlayer = new SeLayer( conn, tableName, "SHAPE"); 09. SeSqlConstructsqlConstruct = new SeSqlConstruct(layer.getName()); 10. if(productId != null) { 11. sqlConstruct.setWhere("yid="+productId.intValue()); 12. } 13. String[] cols = null; 14. if(tableName.equals("YU_AN_POINT") || tableName.equals("FANG_AN_POINT")) { 15. cols = new String[4]; 16. cols[0] = newString("OBJECTID"); 17. cols[1] = layer.getSpatialColumn(); 18. cols[2] = new String("NAME"); 19. cols[3] =new String("IMAGETYPE"); 20. } else { 21. cols = newString[3]; 22. cols[0] = new String("OBJECTID"); 23. cols[1] = layer.getSpatialColumn(); 24. cols[2] = new String("NAME"); 25. } 26. System.out.println("cols.length : " + cols.length); 27. SeQueryquery = new SeQuery(conn, cols, sqlConstruct ); 28. query.prepareQuery(); 29. query.execute(); 30. returnquery; 31. } SDE信息删除操作 [java] view plaincopyprint?01./**02. * 03. * 删除通过列对应的值04. * @param id 值05. * @param column 列 06. * @param tbName 表名07. * @throws SeException08. */ 09. public void deletePointObject(String id, String column, String tbName) throwsSeException { 10. SeConnection conn = null; 11. SeLayerlayer = null; 12. SeDelete delete = null; 13. try { 14. conn = this.getConnection(); 15. layer = newSeLayer(conn, tbName, "SHAPE"); // 得到对应图层 16. if (layer ==null) { 17. throw new Exception("找不到空间表:" + tbName); 18. } 19. conn.startTransaction(); 20. delete = new SeDelete(conn); 21. delete.fromTable(layer.getName(), column + "='" + id+"'"); 22. conn.commitTransaction(); 23. } catch (Exception ex) { 24. conn.rollbackTransaction(); 25. } finally { 26. if (delete != null) { 27. try { 28. delete.close(); 29. } catch(SeException e) { 30. e.printStackTrace(); 31. throw e; 32. } finally { 33. if (conn != null) { 34. conn.close(); 35. } 36. } 37. } 38. } 39. }