/**获取本图层关联的字段名和字段别名
*
* @return 字段名和字段别名
*/
public java.util.Map<String, String> getFields()
{
final Command<java.util.Map<String, String>> queryCmd = new Command<java.util.Map<String, String>>(){
@Override
public java.util.Map<String, String> execute(ISession session, SeConnection seConn) throws SeException,IOException {
java.util.Map<String, String> fieldNames = new HashMap<String,String>();
//取得class的ID编号
SeSqlConstruct objIdSeSql = new SeSqlConstruct("SDE.GDB_OBJECTCLASSES");// 构建空间查询表达式
String[] Qcols1= new String[1];
Qcols1[0] ="ID";
StringBuilder sqlSb = new StringBuilder();
sqlSb.append("NAME='").append(lyrName).append("'");
objIdSeSql.setWhere(sqlSb.toString());
final SeQuery query1 = new SeQuery(seConn, Qcols1, objIdSeSql);
query1.prepareQuery();
query1.execute();
SeRow row1 = query1.fetch();
if(row1==null)return fieldNames;
int objId =row1.getInteger(0);
if(objId<=0)return fieldNames;
query1.close();
String[] Qcols= new String[2];
Qcols[0]="FIELDNAME";
Qcols[1]="ALIASNAME";
StringBuilder sb = new StringBuilder();
sb.append("CLASSID=").append(objId);
SeSqlConstruct sqlCons = new SeSqlConstruct("SDE.GDB_FIELDINFO");// 构建空间查询表达式
sqlCons.setWhere(sb.toString());
final SeQuery query2 = new SeQuery(seConn, Qcols, sqlCons);
query2.prepareQuery();
query2.execute();
SeRow row2 = query2.fetch();
while(row2!=null)
{
String name = row2.getString(0);
String alias = row2.getString(1);
fieldNames.put(name, alias);
row2 = query2.fetch();
}
query2.close();
return fieldNames;
}
};
try
{
return this.sdeSession.issue(queryCmd);
}
catch(Exception ex)
{
ex.printStackTrace();
return Collections.emptyMap();
}
}
ArcSDE SDK获取SDE注册字段名
最新推荐文章于 2021-03-05 17:56:47 发布