ArcSDE C-API 开发:读取属性数据

5 篇文章 0 订阅

很难得看到的Arcsde C API的sample,连官方网站上都是提供的java的,特此收录,转自http://www.gispower.org/article/arcgis/ao/2007/1113/0711132158575H3JBA9K9D4202D084ED.htm

 

 

SE_CONNECTION Connection;

SE_STREAM Stream;

SE_SQL_CONSTRUCT *sqlc

SE_ERROR Connect_error;

LONG rc, population;

SHORT num_cols;

LFLOAT area;

CHAR *server, *instance, *database, *user, *passwd;

CHAR **attrs, *name;

 

/* Connect to ArcSDE */

rc = SE_connection_create

(server, instance, database, user, passwd, &Connect_error, &Connection);

/* See Error handling section for check_error function code. */

check_error(Connection, NULL, rc, "SE_connection_create");

 

/* Create a stream for the query */

rc = SE_stream_create (Connection, &Stream);

check_error(Connection, NULL, rc, "SE_stream_create");

 

/* Allocate an SE_SQL_CONSTRUCT */

rc = SE_sql_construct_alloc (1, &sqlc);

check_error(Connection, NULL, rc, "SE_sql_construct_alloc");

 

/* Fill in the details of the SQL query */

sqlc->where = malloc(20);

sqlc->num_tables = 1;

strcpy (sqlc->tables[0], "cities");

strcpy (sqlc->where, "population < 10000");

 

/* Define the number and names of the table columns to be returned */

num_cols = 3;

attrs = (CHAR **) malloc (num_cols * sizeof(CHAR *));

attrs[0] = "city_name";

attrs[1] = "area";

attrs[2] = "population";

 

/* Define the stream query */

rc = SE_stream_query (Stream, num_cols, attrs, sqlc);

check_error(NULL, Stream, rc, "SE_stream_query");

 

rc = SE_stream_execute (Stream);

/* Iterate over the results */

while (rc == SE_SUCCESS)

{

rc = SE_stream_fetch (Stream);

if (rc == SE_SUCCESS)

{

rc = SE_stream_get_string (Stream,1,name);

check_error(NULL, Stream, rc, "SE_stream_get_string");

 

rc = SE_stream_get_double (Stream,2,&area);

check_error(NULL, Stream, rc, "SE_stream_get_double");

 

rc = SE_stream_get_integer (Stream,3,&population);

check_error(NULL, Stream, rc, "SE_stream_get_integer");

 

/* Now do something with the name, area and population */

}

}

 

/* Release the stream when it is no longer needed */

rc = SE_stream_free (Stream);

free (attrs);

free (sqlc->where);

undefined undefined undefined undefinedSE_sql_construct_free (sqlc);

 

/* Disconnect from ArcSDE */

undefined undefined undefined undefinedSE_connection_free (Connection);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值