ArcSDE SDK介绍


对广大用户来说,ArcSDE SDK对用户来说一直是比较神秘的,因为ArcSDE SDK只在ArcSDE9.3的光盘上跟ArcSDE安装介质整合到一块,也就是在这个版本被用户所熟知和使用,但是从ArcSDE9.3.1版本又神秘的失踪了,这让很多用户对ArcSDE SDK的神秘性很是好奇,而且还有不少用户也钟情于使用ArcSDE SDK。

Tips:目前比较流行的开发手段包括:

  • ArcGIS Engine\ArcObject
  • SQL操作ST_Geometry
  • ArcSDE SDK
  • Web API
  • Mobile API
  • Other

如果是ArcGIS Engine、ArcObject开发是名门正派的话,SQL操作和SDK就属于旁门左道,毕竟后两者的开发需要开发人员比较深厚的编程能力、数据库能力以及ArcSDE的深入了解等,那么就介绍一下ArcSDE SDK。

ArcSDE SDK跟ArcSDE是可以类比的,这个类比就是开发需要版本相一致,而且ArcSDE SDK也是分64Bit和32Bit的,而且ArcSDE SDK也包括C API和Java API两种

Tips:从上面的内容我们可以获得,如果ArcSDE打上相关的SP补丁,那么ArcSDE SDK也同步即可

           既然SDK分32Bit和64Bit,那么编译器的位数最好也与SDK一致

先把ArcSDE SDK的帮助文档呈现给大家:http://help.arcgis.com/en/geodatabase/10.0/sdk/arcsde/welcome.htm

该帮助文档包括:概念介绍、API介绍、典型例子:

Tips:这里的概念最经典的就是对版本的介绍,大家可以看看,这可是在ArcGIS桌面帮助里面找不到的

  • Database connections
  • Geometry (Coordinate reference, coordinate systems and projections, types of shapes, spatial reference systems)
  • Log files
  • Rasters
  • Schema objects (Tables, Layers, Locking)
  • Unicode support
  • Versioning
  • XML
从上面看,就是ArcSDE SDK主要可以完成的相关功能,简单说一下:

1:可以进行ArcSDE的数据连接(完全废话)、那么也可以进行版本的相关操作、ArcSDE实例的管理

2:矢量数据的操作(编辑、查询、投影修改等)

3:影像数据的操作

4:ArcSDE Schema的操作

5:其他用户用的比较少的比如log files、XML等

Tips:其实不管是使用SQL操作还是SDK,相关的操作对象都是简单对象(点、线、面),那么如果你还有复杂对象的话,那只能使用ArcGIS Engine或者ArcObject了,这是用户在选择开发方式需要结合自己的项目需求来自行评定的。



以Java API做一个简单描述

ArcSDE Java API提供了一个开放的、高层次的编程接口,以处理与分析空间信息。它包含了三个java包:Client包、Geometry包、以及Projection包。
  • Client包提供了实现ArcSDE服务器相关的功能的类。利用这个包建立的应用程序,能建立一个到ArcSDE实例的连接,查询一个层,或者与ArcSDE服务器进行通讯。
  • Geometry包提供了实现OGC(开源GIS)几何学功能接口的类。
  • Projection包提供了定义一个坐标系统与在不同坐标系统中转换的功能的类。

下面的主题对ArcSDE Java API的功能进行了大体的介绍。
如果安装完毕ArcSDE SDK,会自动安装在ArcSDE的目录下:%SDEHOME%=C:\Program Files\ArcGIS\ArcSDE\ora11gexe
那么最主要的有C:\Program Files\ArcGIS\ArcSDE\lib和C:\Program Files\ArcGIS\ArcSDE\bin,相关的dll和Jar文件

During ArcSDE client installation, the following files are installed:

File Description
jsde_sdk.jar Contains the ArcSDE Client, and Geometry Java API class files.
jpe_sdk.jar Contains the ArcSDE Projection Engine Java API class files.
concurrent.jar Provides standardized, efficient versions of utility classes commonly encountered in concurrent Java programming.
icu4j_3_2.jar ICU4J libraries required for globalization.

以上是相关的jar包介绍,那么我在搭建相关环境需要注意什么呢?


UNIX Windows
Set the SDEHOME environment variable to the ArcSDE home directory, and include the %SDEHOME%/bin in the PATH environment variable. Also set the ORACLE_HOME environment variable.

The following DLLs are required for direct connect support.

File Description
sdejavautil.dll This modules contains the ArcSDE direct connect library functions.
gsrvr*93.dll This modules contains the ArcSDE direct connect library functions.
sde*gsrvr93.dll This modules contains the ArcSDE direct connect library functions.
sde.dll This modules contains the ArcSDE client library functions.
sg.dll This modules contains the ArcSDE shape library functions.
pe.dll This modules contains the ArcSDE pe library functions.
xerces*.dll This modules contains the XML parser library functions.
icu*.dll This modules contains the Unicode support library functions.

以上是相关的bin文件介绍,windows 和非Windows不一样,非windows需要在bash_profile和profile文件里面进行引用。


以Windows操作系统、Eclipse为例:
注意:确保SDK位数和Eclipse位数一致
1:将SDK的bin 文件里面的dll拷贝到%SDHOME%/bin文件里面,注意这两个路径,这样就可以在环境变量引用SDK的dll了
2:在Eclipse里创建新工程时,引用jar包
ArcSDE SDK介绍_第1张图片

剩下的如果你熟悉Java开发,就开始吧...

在开发过程中还是多看看相关的帮助,ArcGIS的帮助做的一直非常好,比如我们需要了解一下查询的开发
从查看API很容易看到SeQuery,当我们打开该API,帮助就会给我们提供开发查询的具体步骤:
Used to submit a query to an ArcSDE instance.

A typical SeQuery operation sequence is:
1) Create an SeQuery.
2) Prepare the query.
3) Execute a statement or spatial query.
4) Fetch a single SeRow from the SeQuery.
5) Retrieve column values and feature geometry from the fetched SeRow.
6) Close the SeQuery at the end of a series of fetches.
那么我们在开发过程中就非常方便了。

特别注意:如果用户选择使用SDK开发,还需要明白一件事情就是,如果有什么开发的问题,是需要用户自己来解决的,Esri中国是不做技术支持的,这个一定要知道。

开发参考:http://blog.csdn.net/warrenwyf/article/category/705061

附赠相关的代码参考

package lish.test;
import com.esri.sde.sdk.client.*;
import com.esri.sde.sdk.client.SeTable.*;
import java.util.Vector;
public class test {
	
	private static SeConnection conn = null;

	private static String server = "192.168.205.142";
	private static String instance = "5353";
	private static String database = "";
	private static String username = "sde";
	private static String password = "sde";
	//获得ArcSDE连接
	private static SeConnection getConn() {
		if (conn == null) {
			try {
				conn = new SeConnection(server, instance, database, username,
						password);
			} catch (SeException ex) {
				ex.printStackTrace();
			}
			
		}
	    
		return conn;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		GetArcSDEInfo(); 
	}
	//ArcSDE管理
	public static void GetArcSDEInfo()
	{
		try 
		{ 
			SeInstance instance = new SeInstance(server, "5353");
			SeInstance.SeInstanceStatus status = instance.getStatus(); 
			System.out.println("连接数:"+status.getNumConnections());
			System.out.println("可以连接:"+status.isAccepting()); 
			
			System.out.println("------------------------------------------------");
			
			SeInstance.SeInstanceConfiguration config = instance.getConfiguration();
			System.out.println("最大连接数:"+config.getMaxConnections());
			
			System.out.println("------------------------------------------------");
			
			SeInstance.SeInstanceStats[] stats=instance.getStats();
			for (int i=0;i<stats.length;i++)
			{
				System.out.println("操作数:"+stats[i].getOperationCount());
			}
			
			System.out.println("------------------------------------------------");
			
			SeInstance.SeInstanceUsers[] users=instance.getUsers();
			 for(int j=0;j<users.length;j++)
			 {
				 System.out.println("用户名:"+users[j].getUserName());
				 System.out.println("系统名:"+users[j].getSysName());
				 System.out.println("服务器开始时间:"+users[j].getServerStartTime());
				 System.out.println("服务器PID:"+users[j].getServerPid());
				 System.out.println("*****************************");
			 }
			 
			 System.out.println("------------------------------------------------");
			 System.out.println("系统名:"+instance.getServerName());
			 System.out.println("------------------------------------------------");
			 
			 System.out.println("------------------------------------------------");
			 SeInstance.SeInstanceTableLocks[] tablelocks=instance.getTableLocks();
			 for(int i=0;i<tablelocks.length;i++)
			 {
				 System.out.println("表级别锁类型:"+tablelocks[i].getLockType());
				 System.out.println("表级别锁PID:"+tablelocks[i].getPid());
				 System.out.println("表级别锁注册ID:"+tablelocks[i].getRegistrationId());
				 System.out.println("*****************************");
			 }

			 System.out.println("------------------------------------------------");
			 
		}
			
		catch (SeException e) { e.printStackTrace(); }
	}
	//空间条件查询
	public static void SpatialQuery()
	{
		try {
			SeConnection conn = getConn();
			SeLayer layer = new SeLayer(conn,"quxian","SHAPE");

			SeTable table = new SeTable(conn, "quxian");
			SeColumnDefinition[] tableDef = table.describe();
			String[] cols = new String[tableDef.length];
			for (int j = 0; j < cols.length; j++)
			{
				cols[j] = tableDef[j].getName();
			}
			SeCoordinateReference cr = layer.getCoordRef();
			SeFilter[] filters = new SeFilter[1];
			SeShape shape = new SeShape(cr); 
			shape.generateFromText("POLYGON((125.091 44.324,125.070 43.428,125.887 44.027,125.091 44.324))");
			
			//SDEPoint pt = new SDEPoint(125.091,44.324);
			//shape.generatePoint(1, new SDEPoint[] { pt });
			SeFilter filter = new SeShapeFilter(layer.getName(), layer
					.getSpatialColumn(), shape, SeShapeFilter.METHOD_ENVP);
			filters[0] = filter;

			SeSqlConstruct sqlCons = new SeSqlConstruct(layer.getName());
			SeQuery query = new SeQuery(conn, cols, sqlCons);
			query.prepareQuery();
			query.setSpatialConstraints(SeQuery.SE_OPTIMIZE, false,filters);
			query.execute();
				SeRow row =query.fetch();
				while(row!=null)
				{
					System.out.println(row.getObject(1).toString());
					
					row =query.fetch();
				}
		}
		catch (Exception ex) {
			ex.printStackTrace();
		}
	}
	//属性条件查询 
	public static void AttributeQuery()
	{
		try {
			SeConnection conn = getConn();
			SeTable table = new SeTable(conn, "quxian");
			SeColumnDefinition[] tableDef = table.describe();
			String[] cols = new String[tableDef.length];
			for (int j = 0; j < cols.length; j++)
			{
				cols[j] = tableDef[j].getName();
			}
			SeSqlConstruct sqlCons = new SeSqlConstruct("quxian");
			sqlCons.setWhere("CITY='长春市'");
			SeQuery query = new SeQuery(conn, cols, sqlCons);
			
			query.prepareQuery(cols,sqlCons);
				query.execute();
				SeRow row =query.fetch();
				while(row!=null)
				{
					System.out.println(row.getObject(1).toString());
					System.out.println(row.getObject(4).toString());
					row =query.fetch();
				}
		}
		catch (Exception ex) {
			ex.printStackTrace();
		}
	}
	//普通查询
	public static void CommonQuery()
	{
		try {
			SeConnection conn = getConn();
			SeTable table = new SeTable(conn, "conn");
			SeColumnDefinition[] tableDef = table.describe();
			String[] cols = new String[tableDef.length];
			for (int j = 0; j < cols.length; j++)
			{
				cols[j] = tableDef[j].getName();
			}
			SeSqlConstruct sqlCons = new SeSqlConstruct("conn");
			SeQuery query = new SeQuery(conn, cols, sqlCons);

				SeQueryInfo queryInfo = new SeQueryInfo();
				queryInfo.setQueryType(SeQueryInfo.SE_QUERYTYPE_ATTRIBUTE_FIRST);
				queryInfo.setColumns(cols);
				queryInfo.setConstruct(sqlCons);
				query.prepareQueryInfo(queryInfo);
				query.execute();
				SeRow row =query.fetch();
				while(row!=null)
				{
					System.out.println(row.getObject(0).toString());
					row =query.fetch();
				}
		}
		catch (Exception ex) {
			ex.printStackTrace();
		}
	}
	//获得ArcSDE版本信息
	public static void GetVersion()
	{
		SeConnection conn =getConn();
		SeRelease release=conn.getRelease();
		System.out.println(release.getBugFix());
		System.out.println(release.getDesc());
		System.out.println(release.getRelease());
		System.out.println(release.getMajor());
		System.out.println(release.getMinor());
		
	}


-------------------------------------------------------------------------------------------------------
版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!
------------------------------------------------------------------------------------------------------

你可能感兴趣的:(ArcSDE SDK介绍)